Comment #7 on issue 616 by [email protected]: JSON.parse doesn't accept
strings contain new lines
http://code.google.com/p/v8/issues/detail?id=616
Yes, that description is correct. The string literal in the JS code is
parsed by the JS parser so that the resulting string contains a single
newline character, not the '\','n' character sequence. Passing that to
JSON.parse gives a syntax error.
If you get a string from somewhere else that contain the '\','n' character
sequence in a JSONString value, it will be parsed by the JSON parser to
create a string value containing the newline character.
It's a general problem when you embed one language into a string value of
another language - both languages' escapes must be considered. It's the
same with RegExps:
/\w+/ vs. RegExp("\\w+")
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev