What is JSON?

Sharing is Caring

JSON is an open standard format for exchanging data. It uses a human-readable text to store data. JSON stands for JavaScript Object Notation. It uses key value pairs and arrays.

Douglas Crockford (writer of JavaScript: The Good Parts) popularized the format in the early 2000’s. In 2013, JSON was standardized as ECMA-404, and RCF 8259 was published in 2017.

Why does JSON matter?

In the early 2000’s AJAX powered websites started to take over, parsing XML can be pretty heavy and error laden at times. A new easier parsing method was needed the result was JSON.

As of right now (2022), it’s the defacto standard for APIs to take requests and respond with.

Why not just use XML?

  • Less Verbose: JSON follows a more compact style to improve readability.
  • Faster: The JSON parsing process is faster than that of the XML because the DOM manipulation library in XML requires extra memory for handling large XML files. JSON requires less space which results in lower cost and increased parsing speed.
  • Readable: The JSON structure is easily readable and straightforward. Regardless of the programming language that you are using, you can easily map the domain objects.
  • Structured Data: In JSON, a map data structure is used, whereas XML follows a tree structure. The key-value pairs limit the task but facilitate the predictive and easily understandable model.

How is JSON structured?

JSON is structured primarily by key value pairs.

  • Key: The key is always a string enclosed in quotation marks.
  • Value: A value that can be an array, boolean, number, string or other object.

An example key and value:

	"myKey": "myValue"

The key is “myKey” and the value is “myValue”.

If you need to use an array of objects, we can replace the brackets with with square brackets.

	"myKey": "myValue"
}, {
	"myKey": "someValue"
Sharing is Caring

Leave a Reply

Your email address will not be published.