Exploring the JSON specification
JSON stands for JavaScript Object Notation, and is a lightweight data-interchange format. It is easy for humans to read and write, and it is easy for machines to parse and generate.
We can easily convert a JavaScript object to a JSON string using the JSON.stringify()
method:
const user = { name: 'John', age: 30 }; const json = JSON.stringify(user);
And we can convert a JSON string to a JavaScript object using the JSON.parse()
method:
const json = '{"name":"John","age":30}'; const user = JSON.parse(json);
While the JSON name includes the world JavaScript, it is a language-independent data format. Many programming languages have libraries to parse and generate JSON.
JSON is the most common format used to exchange data between clients and servers, such as when we use or build a REST API.
Important note
The JSON specification is quite simple, and I strongly suggest...