javascript - Why can't I use ' instead of " for JSON string? -
i have basic json string, surprise got error :
json unexpected token @ position 1
https://jsfiddle.net/5l2sgr57/
var jsonstring = "{'name': 'john'}"; json.parse(jsonstring);
it works if switch ' " reason need since in javascript string ' , " supposedly equivalent ?
switch single , double quotation marks
var jsonstring = '{"name": "john"}'; json.parse(jsonstring);
json not equal javascript
json text format language independent uses conventions familiar programmers of c-family of languages, including c, c++, c#, java, javascript, perl, python, , many others. these properties make json ideal data-interchange language. (www.json.org)
you can verify allowed json syntax here
in syntax-definition string, can see '
is not allowed.
Comments
Post a Comment