Escaping special characters in JSON / list of invalid characters to strip from JSON string code example

Example: Escaping special characters in JSON / list of invalid characters to strip from JSON string

A JSON string must be double-quoted, according to the specs, so you don't need to escape '.
If you have to use special character in your JSON string, you can escape it using \ character.

See this list of special character used in JSON :

\b  Backspace (ascii code 08)
\f  Form feed (ascii code 0C)
\n  New line
\r  Carriage return
\t  Tab
\"  Double quote
\\  Backslash character

For new readers, always use a double quotes for your json strings.