像这样的json
{
"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": ""
}
]
}
我怎么能把它解码成java类?
我写了一个像
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;
}
}
并读取 json
ObjectMapper mapper = new ObjectMapper();
UploadedInfoObjEx uploadedInfoObjEx = mapper.readValue(jsonString, UploadedInfoObjEx.class);
错误是
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?)
在 [来源:java.io.StringReader@4150c480;行:1,列:81](通过引用链:com.rayboot.wl.object.UploadedInfoObjEx["infoItems"])
任何人都可以帮助我吗?谢谢