Reputation: 6449
friends
This is my code
var j = '[{"id":"151","name":"As aventuras de PI","picture":null}]'
JSON.parse(j)
and it keeps saying "unexpected token"
This happens in the main page of my website. But in many other pages it works fine and I use the same functions (in PHP and in Javascript) to generate this string
Whats wrong with my JSON?
Upvotes: 0
Views: 80
Reputation: 6449
Saved the file as UTF-8 without BOM (used Notepad++ for that) and that fixed the error
Upvotes: 0
Reputation: 943564
You have a non-printing character between '
and [
.
Copy/pasting your code to jsbin makes it visible:
Delete those three characters and retype them.
Upvotes: 5