user3553401
user3553401

Reputation: 109

JSON parse error incorrect character

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

Answers (2)

Danny Blue
Danny Blue

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

shf301
shf301

Reputation: 31394

JSON requires double quotes around strings:

var resu = JSON.parse("{\"Tourney\":{\"clubID\":\"5801133T\",\"tourneyID\":\"TPP27082014S\",\"Title\":\"Mon petit tournoi\"}}");

Upvotes: 2

Related Questions