JSON ≠ JavaScript Object Literal
#16
· 2021-01-28
· JavaScript, JSON
- JSON
is a text format that is completely language independent but uses conventions that are familiar to programmers of [...] JavaScript
.
- A JavaScript object
is a comma-delimited list of zero or more pairs of property names and associated values of an object, enclosed in curly braces ({}
)
.
const objectLiteral = {foo: 'bar'};
const jsonString = '{"foo": "bar"}';
const notJsonAnymore = JSON.parse(jsonString);
const jsonString2 = JSON.stringify(objectLiteral);