我正在尝试使用 jackson api 中的 ObjectMapper 类将以下 JSON 转换为 Java 对象,但出现错误。我的 java 类应该是什么样子?
[{
"saleValue": 100,
"priceEventTypeCode": 1,
"startDate": "2016-03-23T18:00:00.0Z",
"updateStoredValue": true,
"autoRound": false,
"priceChangeNumber": "tkt"
},
{
"saleValue": 100,
"priceEventTypeCode": 1,
"startDate": "2016-03-23T18:00:00.0Z",
"updateStoredValue": true,
"autoRound": false,
"priceChangeNumber": "tkt"
}]
如果我有以下 json,我可以将其转换为 java 对象。
public class Pid
{
private String priceChangeNumber;
private String startDate;
private String autoRound;
private String priceEventTypeCode;
private String saleValue;
private String updateStoredValue;
// getter and setter functions removed here.
}
杰森:
{
"saleValue": 100,
"priceEventTypeCode": 1,
"startDate": "2016-03-23T18:00:00.0Z",
"updateStoredValue": true,
"autoRound": false,
"priceChangeNumber": "tkt"
}