如何放心地序列化java关键字
我正在使用放心的编程语言 JAVA 测试 API,我面临着将 JSON 有效负载序列化为 java 对象的问题。 我有一个以下 JSON 有效负载:
{
"orderId": "Ybpv82lJ",
"total": "5",
"currencyId": "Belm3pnb",
"localCurrencyRate": 1,
"for": "2218",
"recipientName": "new Order",
"numberOfPayments": 1,
"holderFullName": "Name ",
"holderIdNumber": "123456",
"lastFourDigits": "4544",
"timezone": 360
}
正如您在上面的 JSON 有效负载中看到的,我有一个 java 保留关键字 for
所以当我创建 POJO 类时,我遇到了这个问题 ,我有以下 POJO 类
@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;
}
我该如何处理它,如果您有任何想法请帮助我,提前感谢!
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 !
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
此解决方案可能会帮助您:
This solution might help you: