2021-01-14 15:01:13
如json字符串:{"contend":[{"bid":"22","carid":"0"},{"bid":"22","carid":"0"}],"result":100,"total":2}
下面直接附代码:
https://json字符串 String jsondata="{\"contend\":[{\"bid\":\"22\",\"carid\":\"0\"},{\"bid\":\"22\",\"carid\":\"0\"}],\"result\":100,\"total\":2}"; JSONObject obj= JSON.parseObject(jsondata); https://map对象 Map<String, Object> data =new HashMap<>(); https://循环转换 Iterator it =obj.entrySet().iterator(); while (it.hasNext()) { Map.Entry<String, Object> entry = (Entry<String, Object>) it.next(); data.put(entry.getKey(), entry.getValue()); } System.out.println("map对象:"+data.toString());
下面是输出内容:
{total=2, contend=[{"carid":"0","bid":"22"},{"carid":"0","bid":"22"}], result=100}
https://map对象 Map<String, Object> data =new HashMap<>(); String x =JSONObject.toJSONString(data); System.out.println("json字符串:"+x);
下面是输出内容:
{"total":2,"result":100,"contend":[{"carid":"0","bid":"22"},{"carid":"0","bid":"22"}]}
原文链接:http://www.yuepc.com/a/1821.html
http://www.yuepc.com 为 “沈一博客” 唯一官方服务平台,请勿相信其他任何渠道。
2021-06-13
2021-01-15
2021-06-07
2021-03-09
2021-05-01
2021-06-08
2021-05-10
2021-05-12
2021-06-06
2021-06-11