I have the following JSON string encoded using PHP 5.2 json_encode ():
{"foo":"\\."}
This JSON string is valid. You can check it out at http://www.jsonlint.com/
But the native JSON.parse () method (Chrome, Firefox) causes the following error when parsing:
SyntaxError: Unexpected token ILLEGAL
Do any of you know why I cannot parse metacharacters with a regular expression?
This example works:
{"foo":"\\bar"}
But this also fails:
{"foo":"\\?"}
BTW: \. is just a simple test regular expression that I want to run through a JavaScript RegExp object.
Thanks for your support,
Dyvor
json javascript firefox google-chrome regex
BaggersIO
source share