[{'a':'1','b':'2'},{'c':'3','d':'4'}]"
解决
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
public static void main(String[] args) {
String invoiceStr = "[{'a':'1','b':'2'},{'c':'3','d':'4'}]";
JSONArray invoiceArray = JSONArray.fromObject(invoiceStr);
System.out.println("测试数组: "+invoiceArray.get(0));
JSONObject invoiceObj = JSONObject.fromObject(invoiceArray.get(1));
System.out.println("测试json: "+invoiceObj.get("c"));
}
结果:
测试数组: {"a":"1","b":"2"}
测试json: 3