mirror of
https://github.com/fangyidong/json-simple.git
synced 2025-12-06 07:20:53 +03:00
387 B
387 B
Escaping text that contains special characters
JSONObject.escape() escapes quotes,, /, \r, \n, \b, \f, \t and other control characters. It can be used to escape JavaScript codes.
String s = "\"foo\" is not \"bar\". specials: \b\r\n\f\t\\/";
s = JSONObject.escape(s);
System.out.println(s);
Result:
\"foo\" is not \"bar\". specials: \b\r\n\f\t\\\/