When Json to javaBean, I found an error. It's a NullPointerException. this is Json:
{
"errno": 0,
"msg": "success",
"data": {
"direction": 0,
"words_result_num": 19,
"words_result": [
{
"words": "车辆管理产品资料库",
"probability": {
"variance": 0.006179,
"average": 0.95664,
"min": 0.746422
}
},
{
"words": "盛简体中文",
"probability": {
"variance": 0.052477,
"average": 0.84753,
"min": 0.407953
}
},
{
"words": "户姓名段红车辆:BW53 5 i ( wbasp2101cDR76734}内莎利号,BMEW43999",
"probability": {
"variance": 0.030252,
"average": 0.856571,
"min": 0.503605
}
},
{
"words": "保险公司",
"probability": {
"variance": 0.045034,
"average": 0.847951,
"min": 0.48522
}
}
]
}
}
This is my Json to javaBean method:
public String OCRbyJSON(){
OCRResultVo ObjResult = null ;
if(StringUtils.isNotBlank(strJson)){
try {
JSONObject jsStr = JSONObject.fromObject(strJson);
jsStr.remove("unknown");
ObjResult = (OCRResultVo) JSONObject.toBean(jsStr,OCRResultVo.class);
System.out.println("");
} catch (Exception e) {
e.printStackTrace();
}
}
return NONE;
}
OCRResultVo Class:When I paste it, I omit the methods of Getting () and Setting ().And JSONObject is net.sf.json.JSONObject;
public class OCRResultVo {
private String errno;
private String msg;
private JSONObject data;
}
I am most confused is that if I remove JSON inside the "words_result": the content, there is no problem. So I do not know where it was wrong, is wrong with the type, or with the wrong way ........ If you need other information, please tell me. thanks everybody.
Aucun commentaire:
Enregistrer un commentaire