fastjson与各类型的转换

参考:https://www.cnblogs.com/ceshi2016/p/7381478.html

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

/**map转Json对象**/
Map<String, String> map = new HashMap<String, String>();
JSONObject jsonObject = JSONObject.parseObject(JSON.toJSONString(map));
/**Json对象转map**/
Map<String, Object> map2 = JSONObject.toJavaObject(jsonObject, Map.class);


/**将List转换成JSONArray**/
List<String> list = new ArrayList<String>();
JSONArray jsonArray = JSONArray.parseArray(JSON.toJSONString(list));
/**将JSONArray转换成List**/
http://www.cnblogs.com/goody9807/p/4244862.html


/**字符串转Json对象**/
String jsonInfo = "";
JSONObject jsonObject2 = JSONObject.parseObject(jsonInfo);
/**字符串转Json对象**/
String jsonStrng = JSON.toJSONString(jsonObject2);

猜你喜欢

转载自www.cnblogs.com/ying-chease/p/9188191.html
今日推荐