Json解析报错:com.alibaba.fastjson.JSONException: syntax error, expect {, actual string, pos 0, fastjso
json
适用于现代 C++ 的 JSON。
项目地址:https://gitcode.com/gh_mirrors/js/json
·
背景:系统A调用了B系统的接口,原代码:
JSONObject.parseObject(data, 实体.class);
data的格式:{
"name":“111”;
“type”: "1"
}
实体class{
name;
type;
get/setxx
}
后来B系统的返回参数变化成:既带有实体,也带有属性。
{
result :{
"name":“111”;
“type”: "1"
},
"sign": “sssssss”
}
新定义实体:
实体class{
result;---------对象类,包含name,type
sign
get/setxx
}
报错:JSONException: syntax error, expect {, actual string, pos 0, fastjso 无法解析。
解决方法:
-
JSONObject data=JSON.parseObject(data);
-
Result result =JSON.parseObject(data.getString("result"));
String sign = JSON.parseObject(data.getString("sign "));
参考链接:
适用于现代 C++ 的 JSON。
最近提交(Master分支:3 个月前 )
2d42229f
* Support BSON uint64 de/serialization
Signed-off-by: Michael Valladolid <mikevalladolid@gmail.com>
* Treat 0x11 as uint64 and not timestamp specific
Signed-off-by: Michael Valladolid <mikevalladolid@gmail.com>
---------
Signed-off-by: Michael Valladolid <mikevalladolid@gmail.com> 7 天前
1809b3d8
Signed-off-by: Niels Lohmann <mail@nlohmann.me> 8 天前
更多推荐



所有评论(0)