json字符串转化为对象
String jsonString = "{name:'Antony',age:'12',sex:'male',telephone:'88888'}";
Staff staff = JSON.parseObject(jsonString, Staff.class);
System.out.println(staff.toString());
对象转化为json字符串
String jsonStr = JSON.toJSONString(staff);
System.out.println(jsonStr);
如何从字符串String获得JSONObject对象和JSONArray对象
JSONObject jsonObject = new JSONObject ( String str);
JSONArray jsonArray = new JSONArray(String str ) ;
如何从JSONArray中获得JSONObject对象
JSONObject jsonObject = (JSONObject)jsonArray.get(i);
JSONObject jsonObject = jsonArray.getJSONObject(i) ;