Here is my string
{
\'user\': {
\'name\': \'abc\',
\'fx\': {
\'message\': {
\'color\': \'red\'
}
I think we all agree single quoted jsons aren't real jsons. Be that as it may, we still need to address the question of escaping " within a double quoted json string, in the absence of libraries to do so for us.
Replacing each " with a \" is NOT ENOUGH: User may enter the input: \ and parsing, again, fails (think why).
Instead, first replace each \ with \ (double backslash). Only then, replace each " with \" (backslash followed by ").