1. 字符串转化成Json对象,获取其中的值
String json ="{"Name":"Langshen","MyWife":["LuLu","26"],"MySon":[{"Name":"Son1"},{"Name":"Son2"},{"Name":"Son3"}]}";
JSONObject obj =JSONObject.parseObject(json);
JSONArray array = obj.getJSONArray("MySon");
for(int i= 0;i<array.size();i++){
JSONObject name = array.getJSONObject(i);
System.out.println(name.get("Name"));
}
2.将对象转成成json字符串
String treeStr =JSON.toJSONString(obj);