java.lang.ClassCastException:com.alibaba.fastjson.JSONArray cannot be cast to JSONObject
fastjson
FASTJSON 2.0.x has been released, faster and more secure, recommend you upgrade.
项目地址:https://gitcode.com/gh_mirrors/fastj/fastjson
免费下载资源
·
public static void main(String[] args) {
List<WeighOrderCartExtendVO> extendVOs = new ArrayList<>();
//根据售卖类型分组
WeighOrderCartExtendVO extendVO = new WeighOrderCartExtendVO();
extendVO.setDishId("e04b0220006813fb");
extendVO.setGoodsWeight(100);
extendVO.setSellType(1);
extendVO.setGoodsNum(10);
extendVOs.add(extendVO);
String extendInfo = JSON.toJSONString(extendVOs);
JSONObject object = JSON.parseObject(extendInfo);
// JSONArray array = JSON.parseArray(extendInfo);
// System.out.println(JSONObject.parseObject(array.get(0).toString()));
}
Exception in thread "main" com.alibaba.fastjson.JSONException: can not cast to JSONObject.
at com.alibaba.fastjson.JSON.parseObject(JSON.java:249)
at com.ut.cook.weigh.order.WeighOrderService.main(WeighOrderService.java:669)
Caused by: java.lang.ClassCastException: com.alibaba.fastjson.JSONArray cannot be cast to com.alibaba.fastjson.JSONObject
at com.alibaba.fastjson.JSON.parseObject(JSON.java:247)
... 1 more
解决: 取出JSONArray中的数据后再解析!
GitHub 加速计划 / fastj / fastjson
3
1
下载
FASTJSON 2.0.x has been released, faster and more secure, recommend you upgrade.
最近提交(Master分支:5 个月前 )
c942c834 - 1 年前
5bc4709b - 1 年前
更多推荐
已为社区贡献8条内容
所有评论(0)