Java net.sf.json 使用json数组
import net.sf.json.JSONArray;import net.sf.json.JSONObject;String s="[{\"index\":0,\"fileName\":\"\",\"path\":\"\"}]";System.out.println(s); //[{"index":0,"fileName":"","path":""}]JSONArray jsonArray=
·
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
String 转json
String str = "{\"result\":\"success\",\"message\":\"成功!\"}";
JSONObject json = JSONObject.fromObject(str);
String 转json数组
String s="[{\"index\":0,\"fileName\":\"\",\"path\":\"\"}]";
JSONArray jsonArray = JSONArray.fromObject(s);
JSONArray jsonArray=new JSONArray();
JSONObject jsonObject=new JSONObject();
jsonObject.put("index",0);
jsonObject.put("fileName","");
jsonObject.put("path","");
jsonArray.add(jsonObject);
System.out.println(jsonArray);//[{"index":0,"fileName":"","path":""}]
更多推荐
已为社区贡献11条内容
所有评论(0)