JSON 去掉轉義字符,value去掉雙引號

1. 去掉json 對應value的 雙引號,例子:json

args 後面的value {} 不帶雙引號
{"code":"998","url":"testURL",,"args":{"pageUrl":"testURL",,"eventName":"test"}}url

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"}}code