javascript - Unexpected Token while Parsing JSON -
this fraustating me 5 hours , have ask question.
i trying parse json using javascript, don't know why getting error on console:
uncaught syntaxerror: unexpected token (…) (anonymous function) @ vm382:2injectedscript._evaluateon @ vm251:904injectedscript._evaluateandwrap @ vm251:837injectedscript.evaluate @vm251:693 json : http://pastebin.com/dddxqj6d
js code:
var json=**big json**; var obj=json.parse(json); tried:
json.stringify(json);
json= "'" + json+ "'";
loading json url
according jsonlint , pastebin posted, json invalid, due use of \'. once replace of them ', should work normally.
in original json file there going occurrences of \\'. string become \'.
if you’re using linux, simple
sed -i "s/\\\\\\\'/\'/g" yourjsonfile.json on file fixes everything.
jsonlint says “valid json” then.
you can try
json.parse(json.replace(/\\'/,'\''));
Comments
Post a Comment