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":""}]