Using the '\n' string (not the EOL character, the string with '\' and 'n') in JSON.parse gives an error. The error happens both in the javascript console and when parsing a sting outside the console. Example: 1. Open the javascript console 2. Type: JSON.parse('["\n"]') This should create a list containing a string with the EOL character, but it gives an error. The bug appears with Epiphany (Linux) and Safari (Windows). No bug with Firefox or Chrome.
Firefox and Chrome are both incorrect -- When you do JSON.parse('"\n"') you are asking for the JSON parser to accept a new line in the middle of a string literal. Because you have not escaped the new line character in the string that you pass to JSON, you have only escaped it in the JS parser. The string passed to JSON.parse must include the escapes so you actually need to do JSON.parse('"\\n"') The \\ escapes the \ when the script is parse, so you are then passing the string "\n" to the JSON parser.
And it's fixed in firefox 4, and i've filed http://code.google.com/p/v8/issues/detail?id=870
Thank you for your very clear explanation, I'm sorry for the noise.