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