开发者社区 问答 正文

fastJson如何将json字符串转为list<javaBean>

String jsonString1 = "{pays:[{companyId:'1',merchantAccountId:'222',paymentChannel:'01'},{companyId:'2',merchantAccountId:'333',paymentChannel:'02'}]}";
String jsonString1 = "[{companyId:'1',merchantAccountId:'222',paymentChannel:'01'},{companyId:'2',merchantAccountId:'333',paymentChannel:'02'}]";
不太清楚上面那种是对的,感觉是第一种对,
但是
List pays =(List) JSON.parseObject(jsonString1, PayInfoAllDTO.class);
会出现类型转换异常,就是说DTO不能转换为List,希望解决过此类问题的大神帮一下,
PayInfoAllDTO.class这里是对的吗?

展开
收起
杨冬芳 2016-07-06 14:25:43 6395 分享 版权
1 条回答
写回答
取消 提交回答
  • IT从业

    问题已经解决,应该是使用parseArray方法,另外String字符串也有问题

    2019-07-17 19:52:05
    赞同 展开评论