1、//將map轉換成jsonObject
JSONObject itemJSONObj = JSONObject.parseObject(JSON.toJSONString(itemMap));
將Map類型的itemInfo轉換成json,再經JSONObject轉換實現。
2、//將jsonObj轉換成Map
Map<String, Object> itemMap = JSONObject.toJavaObject(itemJSONObj, Map.class);
//JOSN.parseObjet()方法同樣可以轉換
3、//將List轉換成JSONArray
JSONArray ja = JSONArray.parseArray(JSON.toJSONString(itemList));
4、//將JSONArray轉換成List
這個涉及功能比較廣,有達人整理的更為完善。
鏈接如下:
http://www.cnblogs.com/goody9807/p/4244862.html
5 json轉成對象
List<ChannelItem> channelItemList = JSON.parseArray(itemJson,ChannelItem.class);