请问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字符串数组,只传递了里面的某个项

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

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

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐