参考:https://www.cnblogs.com/ceshi2016/p/7381478.html
http://www.cnblogs.com/goody9807/p/4244862.html
https://www.cnblogs.com/DreamDrive/p/5778959.html
/**字符串转Json数组,数组元素转Json对象**/
JSONArray array = JSONArray.parseArray(line)); String[] fields = {"lat", "lng", "poi_id", "poi_name", "poi_type", "roadidx"}; if (null != array) { Iterator<Object> iter = array.iterator(); while (iter.hasNext()) { JSONObject json = (JSONObject)iter.next(); for (int i = 0; i < fields.length; i++) { System.out.println(json.getString(fields[i])); } } }
/**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);