json字符串对象和json字符串数组:JSONArray跟JSONObject的区别就是JSONArray比JSONObject多中括号[]
jsonObject:
"Row":{ "YLX":"2010", "ZYY":"变更", "YWH":"60000000020181213", "JYH":"200151" }
jsonArray:
"Row":[ { "YWX":"200", "ZYY":"变更", "YBH":"60000000020181213, "JYH":"200151" } ]
例如:String转json对象:
String formInfos = infoReq.getFormInfos();
JSONObject jsonObject = JSON.parseObject(formInfos);
创建json对象,用put(key,value)拼接json:
JSONObject object = new JSONObject(); jsonObjectRow.put("YWH", projId); jsonObjectRow.put("YWX", "2010"); jsonObjectRow.put("JGXYH", jsonObject.getString("ZJYH"));
创建json数组用add添加json对象(json对象转json数组):
JSONArray jsonArrayRow = new JSONArray(); jsonArrayRow.add(object);
参考文献:http://www.cnblogs.com/xwdreamer/archive/2011/12/16/2296904.html