1. 去掉json 对应value的 双引号,例子:
args 后面的value {} 不带双引号
{"code":"998","url":"testURL",,"args":{"pageUrl":"testURL",,"eventName":"test"}}
JSONObject jsonObject = new JSONObject();
JSONObject args = new JSONObject();
args.put("pageUrl", "testURL");
args.put("eventName", "test");
JSONArray array = new JSONArray();
array.add(args);
jsonObject.put("args", array);
//把jsonarray 的[]去掉,同时去掉转义字符\
String res = StringEscapeUtils.unescapeJavaScript(jsonObject.toString().replace("[", "").replace("]",""));
这样得到的结果就是{"code":"998","url":"testURL",,"args":{"pageUrl":"testURL",,"eventName":"test"}}