JSON example:
{
"locale": "abc",
"passengers": [
{
"address1": "xx",
"address2": "yy",
"city": "London",
"county": "Test",
"dateOfBirthDay": "2",
"dateOfBirthMonth": "1",
"dateOfBirthYear": "1234",
"email": "t@t.com",
"firstName": "first",
"lastName": "test",
"postcode": "xyz",
"telephone": "123131321",
"title": "MR"
},
{
"dateOfBirthDay": "2",
"dateOfBirthMonth": "4",
"dateOfBirthYear": "1234",
"firstName": "date",
"lastName": "change",
"title": "MR"
}
],
"paymentCard": {
"expiryMonth": "5",
"expiryYear": "2222",
"cardNumber": "12345678901234",
"securityCode": "123",
"cardType": "DEL"
},
"token": "{{tokenvalue}}"
}
Code example:
@Getter
@Builder
@ToString
@AllArgsConstructor
private static class sndRequest {
private String adults;
private String children;
}
public String sndRequestMethod(int adults, int children) {
RestAssured.defaultParser = Parser.JSON;
qRequest q1Request = qRequest.builder()
.adults(adults)
.children(children)
.build() ;
String body = gson.toJson(q1Request);
}
This is how I am passing values into the request body, can anyone please help how to pass double list of strings(which I mentioned above) to body with the help of Gson.
How do I send multiple Strings into Passengers? I need something like passengers [ { string1 }, { string 2 } ]
- how do I acheive this format?