Reputation: 109
I'm new to using JSON and I can't figure out why I have this error.
Here is a simple JSON statement:
var resu = JSON.parse("[{'Tourney':{'clubID':'5801133T','tourneyID':'TPP27082014S','Title':'Mon petit tournoi'}}]");
When I run it it says "Incorrect character"...
I tried without the enclosing brackets []. I tried escaping the quotes like this: /'clubID/':/'5801133T/'..
Same error.
Any clue welcome.
Upvotes: 0
Views: 437
Reputation: 463
proper JSON format requires double quotes. the below should fix it.
var resu = JSON.parse("[{\"Tourney\":{\"clubID\":\"5801133T\",\"tourneyID\":\"TPP27082014S\",\"Title\":\"Mon petit tournoi\"}}]");
Upvotes: 0
Reputation: 31394
JSON requires double quotes around strings:
var resu = JSON.parse("{\"Tourney\":{\"clubID\":\"5801133T\",\"tourneyID\":\"TPP27082014S\",\"Title\":\"Mon petit tournoi\"}}");
Upvotes: 2