Files
json-simple/EscapingExamples.md
2015-04-12 20:36:57 -04:00

15 lines
387 B
Markdown

#### 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\\\/
```