dabocaiqq
2018-05-28 10:31
采纳率: 66.6%
浏览 1.3k
已采纳

请问jsonobject转换后数据怎么只有一条了,是list格式的问题吗???

public Object upLoadSettlement(String list) {
JSONObject j = JSONObject.fromObject(list);
System.out.println("我是list"+list);
System.out.println("我是jsonobject转换后的list"+j);
}

输出后
我是list{"YYBH":"400750","JYCKH":"POSJYCKH900000019","POSJYSJ":"20170920082242","SFZHM":"1954651565112","JYLX":"消费","POSJYJE":"5.00","SHH":"306441959121133","ZDBH":"51904698","BHCFYBZ":"1","BZ1":"备注1","BZ2":"备注2","BZ3":"备注3"},{"YYBH":"400750","JYCKH":"XLSYR10HC900000020","POSJYSJ":"20170920085125","SFZHM":"","JYLX":"消费","POSJYJE":"195.50","SHH":"306441959121133","ZDBH":"51904698","BHCFYBZ":"0","BZ1":"备注1","BZ2":"备注2","BZ3":"备注3"}

我是jsonobject转换后的list{"YYBH":"400750","JYCKH":"POSJYCKH900000019","POSJYSJ":"20170920082242","SFZHM":"1954651565112","JYLX":"消费","POSJYJE":"5.00","SHH":"306441959121133","ZDBH":"51904698","BHCFYBZ":"1","BZ1":"备注1","BZ2":"备注2","BZ3":"备注3"}

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

3条回答 默认 最新

  • 已采纳

    你的list就是json对象,不是json数组,那不是只有一条,如果你原来的数组,自己检查list字符串从哪来的,应该没有传递json字符串数组,只传递了里面的某个项

    打赏 评论
  • hyy385 2018-05-28 11:00

    看API,
    JSONObject Accepts JSON formatted strings, Maps, DynaBeans and JavaBeans.
    list要用JSONArray,Accepts JSON formatted strings, arrays, Collections and Enums.

    打赏 评论
  • Android 研发 2018-05-29 03:50

    JsongObject.fromObject() 参数应该用map
    你当前是list , 用JsonArray.fromOject();

    打赏 评论

相关推荐 更多相似问题