JSONArray toString 不要转义符
JSONArray的toString方法默认会对字符串中的特殊字符进行转义,如果不需要转义符,可以使用toString方法的重载方法toString(int indentFactor),设置indentFactor为0,示例如下:
JSONArray jsonArray = new JSONArray(); jsonArray.put("Hello\nWorld!"); jsonArray.put("Hello"World!"); System.out.println(jsonArray.toString(0));
输出结果:
["Hello World!","Hello"World!"]
原文地址: https://www.cveoy.top/t/topic/i2bl 著作权归作者所有。请勿转载和采集!