'How to serialise in rest assured , java keywords
I'm testing API with rest assured programming language is JAVA, I'm facing an issue with serialising JSON payload to java object. I have a following JSON payload:
{
"orderId": "Ybpv82lJ",
"total": "5",
"currencyId": "Belm3pnb",
"localCurrencyRate": 1,
"for": "2218",
"recipientName": "new Order",
"numberOfPayments": 1,
"holderFullName": "Name ",
"holderIdNumber": "123456",
"lastFourDigits": "4544",
"timezone": 360
}
as u can see in above JSON payload , I have a java reserved keyword for
so when I'm creating my POJO class , I'm facing the issue
, I have the following POJO class
@Data
public class CardReceiptRoot {
public Integer localCurrencyRate;
private String for; // this is where I'm facing the issue
private String orderId;
private String currencyId;
private String total;
private String recipientName;
private Integer numberOfPayments;
private String holderFullName;
private String holderIdNumber;
private String lastFourDigits;
private Integer timezone;
}
how can I deal with it , pls help me if u have any ideas , thanks in advance !
Solution 1:[1]
This solution might help you:
import com.fasterxml.jackson.annotation.JsonProperty;
...
@JsonProperty("for")
private String forId;
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
