JSON in Javascript Unexpected Token B
javascript, json
Solution
The parameter for JSON.parse() should be string.
Thus, `JSON.parse(["hello", "world"])` is wrong.
It should be `JSON.parse("[\"hello\", \"world\"]")`
I updated the jsfiddle. Take a look at http://jsfiddle.net/9mJbq/3/
Problem
I'm parsing the following string in JSON http://jsfiddle.net/cjds/9mJbq/2/ When I run it chrome throws up the following error `Unexpected Token B`. Can't figure it out. Because the string is created by PHP json_encode so there shouldn't be a problem with the JSON. I ran it through JSONLint and there was no error so the JSON is fine. So what's the error?