當(dāng)前位置:
首頁 >
前端技术
> javascript
>内容正文
javascript
把执行结果转成json对象报错_JSONObject获取值后为一个对象,将对象转为JSONObject时报错...
生活随笔
收集整理的這篇文章主要介紹了
把执行结果转成json对象报错_JSONObject获取值后为一个对象,将对象转为JSONObject时报错...
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
將json字符串轉(zhuǎn)化成List>對象
Map map = new HashMap();
map.put("key1", "value1");
map.put("key2", "value2");
Map map2 = new HashMap();
map2.put("key1", 1);
map2.put("key2", 2);
List> list = new ArrayList>();
list.add(map);
list.add(map2);
Gson gson = ?new Gson();
String jsonString = gson.toJson(list);
System.out.println("json字符串:"+jsonString);
//解析json字符串
List> list2 = gson.fromJson(jsonString, new TypeToken>>(){}.getType());
總結(jié)
以上是生活随笔為你收集整理的把执行结果转成json对象报错_JSONObject获取值后为一个对象,将对象转为JSONObject时报错...的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: fguillot json rpc_hy
- 下一篇: html 接收 图片流_Microsof