JSON names require double quotes. JavaScript names don't. JSON
{ "name": "John" }
In JavaScript we can have names without quotes:
{ name: "John" }
In JavaScript, keys can be strings, numbers, or identifier names:
{ 12: "John" }
In
JSON
, values must be one of the following data types:
- a string
- a number
- an object (JSON object)
- an array
- a boolean
- null
In
JavaScript
, values can be all of the above listed types, plus any other valid JavaScript expression, including:
- a function
- a date
- a symbol
- undefined
In
JSON
, string values must be written with double quotes:
{ "name":"John" }
In
JavaScript
, we can write string values with double or single quotes:
{ name: 'John' }
by Valeri Tandilashvili
4 years ago
JSON
JavaScript
JS JSON
1
Pro tip: use ```triple backticks around text``` to write in code fences