com.alibaba.fastjson.JSONArray cannot be cast to com.alibaba.fastjson.JSONObject
fastjson
FASTJSON 2.0.x has been released, faster and more secure, recommend you upgrade.
项目地址:https://gitcode.com/gh_mirrors/fastj/fastjson
免费下载资源
·
Exception in thread "main" java.lang.ClassCastException: com.alibaba.fastjson.JSONArray cannot be cast to com.alibaba.fastjson.JSONObject
at com.alibaba.fastjson.JSON.parseObject(JSON.java:164)
at com.alibaba.fastjson.JSON.parseObject(JSON.java:164)
at com.lysoft.business.web.oa.ui.jh_infoPortal.ws.Impl.test.main(test.java:12)
json中类型转换问题,意思是说这样的json不对[ {} ],要使用这样的json格式{}
String str="[{\"id\":1,\"starttime\":\"2017-04-19 15:01\"}]";
str=str.replace("[", "");
str=str.replace("]", "");
因为后台传入的有这样的json[],所以我replace了。
JSONObject jsStr=JSONObject.parseObject(str);
System.out.println(jsStr.get("starttime"));
查询如下:
GitHub 加速计划 / fastj / fastjson
25.69 K
6.51 K
下载
FASTJSON 2.0.x has been released, faster and more secure, recommend you upgrade.
最近提交(Master分支:3 个月前 )
c942c834 - 1 年前
5bc4709b - 1 年前
更多推荐
已为社区贡献3条内容
所有评论(0)