fastjson中Map與JSONObject互換,List與JOSNArray互換的實現

一、//將map轉換成jsonObject html

JSONObject itemJSONObj = JSONObject.parseObject(JSON.toJSONString(itemMap));json

將Map類型的itemInfo轉換成json,再經JSONObject轉換實現。

二、//將jsonObj轉換成Map
Map<String, Object> itemMap = JSONObject.toJavaObject(itemJSONObj, Map.class);post

//JOSN.parseObjet()方法一樣能夠轉換.net

三、//將List轉換成JSONArrayhtm

JSONArray ja = JSONArray.parseArray(JSON.toJSONString(itemList));對象

 

四、//將JSONArray轉換成Listblog

這個涉及功能比較廣,有達人整理的更爲完善。it

連接以下:class

http://www.cnblogs.com/goody9807/p/4244862.htmlList

5 json轉成對象

List<ChannelItem> channelItemList  = JSON.parseArray(itemJson,ChannelItem.class);

轉載:http://blog.csdn.net/lafengwnagzi/article/details/54949125
相關文章
相關標籤/搜索