5

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

 2 years ago
source link: https://dev.to/brijrajparmar27/json-explain-it-to-me-like-im-5-5do2
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

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).


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK