DEV Community

Brijrajsinh parmar
Brijrajsinh parmar

Posted on

JSON, Explain it to me like I'm 5.

It’s basically a way of communicating with someone in writing….but with very specific rules.

In prosaic English, the rules are pretty loose: just like with cage fighting. Not so with JSON. There are many ways of describing something:

• Example 1: Our family has 4 people: You, me and 2 kids.
• Example 2: Our family: you, me, kid1 and kid2.
• Example 3: Family: [ you, me, kid1, kid2]
• Example 4: we got 4 people in our family: mum, dad, kid1 and kid2.

Why don’t they just use plain English instead?

They would, but remember we’re dealing with computers. A computer is stupid and is not going to be able to understand sentences. So we gotta be really specific when computers are involved otherwise they get confused. Furthermore, JSON is a fairly efficient way of communicating, so most of the irrelevant stuff is cut out, which is pretty hand. If you wanted to communicate our family, to a computer, one way you could do so is like this:

“Family”: [“Me”, “Wife”, “Kid1”, “Kid2”]

……and that is basically JSON. But remember, you MUST obey the JSON grammar rules. If you break those rules, then a computer simply will not understand (i.e. parse) what you are writing.
json is similar to filling your name slip on a book cover.


In json your name slip will look like:

"name": "brij",
"class": 1,
"sec": 1,
"subject": "english",
"rollno": 25,
"school": "Public School",
"contact": 123456789

Here the name, subject and school are in quotes because those are strings (words) while class, sec, rollno and contact are written without quotes because they are numeric values (numbers).

Top comments (0)