the json like this
{
"resultCode": "0000",
"resultMsg": "",
"pageCount": "6",
"curPage": "1",
"infoItems": [
{
"sID": "268",
"location": "222",
"unit": "",
"time": "2012-11-02 17:51:46",
"longitude": "111",
"latitude": "222",
"reason": "some",
"dealContent": ""
},
{
"sID": "267",
"location": "fgg",
"unit": "yyg",
"time": "2012-11-02 17:49:14",
"longitude": "111",
"latitude": "222",
"reason": "some",
"dealContent": ""
}
]
}
How could I decode it to java class?
I write a class like
public class UploadedInfoObjEx {
public String resultCode;
public String resultMsg;
public String pageCount;
public String curPage;
public Items[] infoItems;
public class Items {
private String sID;
private String location;
private String unit;
private String longitude;
private String latitude;
private String reason;
private String time;
private String dealContent;
}
}
and read json
ObjectMapper mapper = new ObjectMapper();
UploadedInfoObjEx uploadedInfoObjEx = mapper.readValue(jsonString, UploadedInfoObjEx.class);
the error is
org.codehaus.jackson.map.JsonMappingException: No suitable constructor found for type [simple type, class com.rayboot.wl.object.UploadedInfoObjEx$Items]: can not instantiate from JSON object (need to add/enable type information?)
at [Source: java.io.StringReader@4150c480; line: 1, column: 81] (through reference chain: com.rayboot.wl.object.UploadedInfoObjEx["infoItems"])
anyone could help me? thanks