DEV Community

Cover image for Developer Dictionary - JSON
Bhumi
Bhumi

Posted on • Updated on • Originally published at bhumimakes.com

Developer Dictionary - JSON

This is part of a bigger resource called Developer Dictionary. Read more here

Before we get to what it is, let's talk about why it exists:

Essence:

There are two main things we do with our personal computers and with the network of computers we call The Internet. We collect stuff (data) and we pass stuff around. Passing data around is one of the most common activities that happens on the Internet. So we need some way to format data that is common and understandable by many types of senders and receivers.

For example if you load your twitter profile, your browser sends a request and receives JSON in response. That JSON contains all of the stuff that gets printed on the webpage, in a format that the web page can read and understand. This data was stored on Twitter's servers in database tables, in rows and columns. But the browser needs a way to make sense of the data, along with the labels and what goes together. The essence of JSON data is key/value pairs. So with something like {"color": "green"}, color is the key and green is the value.

Definition of What The Thing Is

Alt Text

The acronym stands for JavaScript Object Notation. It's a human readable format for exchanging data. JSON is often used when data is sent from a server to a web page.

— JSON data is in key/value pairs. Data is separated by commas, curly braces {} hold objects, square brackets [] hold arrays.

— JSON values can be one of these types: string, number, boolean (true or false), array, another nested JSON object, or null.

🥑 In the guacamole recipe JSON above, the key item has string values, the key quantity has number values, the key vegetarian has boolean value, the key ingredients has an array value, and the keys recipes and guacamole both have nested JSON values.

How is it related to JavaScript?

The JSON format looks the same as the code for creating objects in JavaScript. But JSON is not really tied to JavaScript. Reading and writing JSON can be done in any programming language.

Because of the similarity, a JavaScript program can easily convert JSON data into native JavaScript objects using JSON.parse(). If you receive data from a server, in JSON format, you can use it like any other JavaScript object.

Other tidbits / Connections:

— JSON is often used as the response format when data is requested from a service via an API call.

— YAML is very similar to JSON. It offers alternative syntax by replacing all JSON delimiters like {}, [], and " with indentation. YAML supports comments, while JSON does not.

— JSON and XML are similar in that they are both human readable, have nested values, and can be used by many programming languages. They are different in that JSON is shorter, quicker to read and write, and JSON can use arrays. A dedicated XML parser is needed to read XML. JSON can be parsed within a normal JavaScript function.

— JSON replaced XML in the acronym AJAX (Asynchronous JavaScript and XML) from the early 2000's.

That's all there is to it. Now you know the core concept, the essence of The Thing called JSON.


This is part of a bigger resource called Developer Dictionary. Read more here

Top comments (1)

Collapse
 
shaijut profile image
Shaiju T

Hi, I think All read more links are 404 in all posts of this series.