大家好,又见面了,我是你们的朋友全栈君。
String转JSON
String jsonStr= "{status:200,massage:0,result:{id:0987,name:"csdn"}}";
//转json
JSONObject json = JSONObject.fromObject(jsonStr);
JSON转JSONArray
JSONObject json = JSONObject.fromObject("{status:200,massage:0}");
JSONArray array = JSONArray.fromObject(json);
JSONArray转JSON
JSONArray array = JSONArray.fromObject("[{\"id\":\"0987\",\"name\":\"csdn\"},{\"id\":\"0987\",\"name\":\"csdn\"}]");
JSONObject json = array.get(0);
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/151445.html原文链接:https://javaforall.cn