Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java.lang.String cannot be cast to com.alibaba.fastjson.jsonobject #2609

Open
mgliang opened this issue Aug 2, 2019 · 1 comment
Open

java.lang.String cannot be cast to com.alibaba.fastjson.jsonobject #2609

mgliang opened this issue Aug 2, 2019 · 1 comment

Comments

@mgliang
Copy link

mgliang commented Aug 2, 2019

fastjson用的1.2.59;
引用外部数据返回
{
"id": "1233333333333333",
"sign": "dfg/dfgdf/dfgdg/dfgdfg=",
"value": "{"ttt":0,"aaaaa":0}",
"status": "OK"
}
com.alibaba.fastjson.JSONObject resp = JSON.parseObject(res); //1
Map<String,Object> map = resp.getJSONObject("value");// 2
为什么序号2行
测试环境正常 ,生产环境会报java.lang.String cannot be cast to com.alibaba.fastjson.jsonobject;
两个环境配置一样(1.8.0_151),有人遇到同样情况没?

@Omega-Ariston
Copy link
Collaborator

仔细看了下,你的res输入是有问题的:

{
"id": "1233333333333333",
"sign": "dfg/dfgdf/dfgdg/dfgdfg=",
"value": "{"ttt":0,"aaaaa":0}",
"status": "OK"
}

[value]对应的值是非法的:【多了前后双引号】

"{"ttt":0,"aaaaa":0}"

应该是以下才对吧

{"ttt":0,"aaaaa":0}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants