Here is my string
{
\'user\': {
\'name\': \'abc\',
\'fx\': {
\'message\': {
\'color\': \'red\'
}
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
However, even if it is totally contrary to the spec, the author could use \'
.
This is bad because :
But it works, as you want it or not.
For new readers, always use a double quotes for your json strings.