json parse error with double quotes

Javascript unescapes its strings and json unescapes them as well.
the first string ( '{"result": ["lunch", "\"Show\""] }' ) is seen by the json parser as
{"result": ["lunch", ""Show""] }, because \" in javascript means ", but doesn’t exit the double quoted string.

The second string '{"result": ["lunch", "\\\"Show\\\""] }' gets first unescaped to {"result": ["lunch", "\"Show\""] } (and that is correctly unescaped by json).

I think, that '{"result": ["lunch", "\\"Show\\""] }' should work too.

Leave a Comment