Wikipedia says that JSON is designed as non-strict subset of JavaScript, that is addition allows usage of some Unicode characters. Quoting current version as of 2015-11-05:
Though JSON is commonly perceived as being a subset of JavaScript and ECMAScript, it allows some unescaped characters in strings that are illegal in JavaScript and ECMAScript strings.
But.. if I paste any of examples from Wikipedia page in ESLint, it fails with error.
For example I paste this:
{
"id": 1,
"name": "Foo"
}
Into http://eslint.org/demo/ and get:
2:8 - Parsing error: Unexpected token : (undefined)
Looks like colon is illegal in JavaScript for some reason and it is not about unescaped characters in strings.
Why people still call JSON a JavaScript subset?
var x =
. (It'll give you an other error, but it's syntactically fine.)var obj = { "id": 1, "name": "Foo" }
var x=1
is JS, it doesn't mean it works anywhere, exvar y= var x=2