What is JSON?
How I Explained JSON to my Wife:
What is JSON? – Simple Explanation
Me: “It’s basically a way of communicating with someone. “
Wife: “What do you mean by that?”
Me: “Well imagine if I wanted to communicate with your mother – via writing mind you. How do you suppose I would do it?
Wife: Well you’d write out a letter in English I suppose.
Me: Bingo! Exactly. I’d write something in English. And your mother presumably understands English. So she would be able to understand what I wrote down and respond accordingly.
Wife: So JSON is basically writing to someone in English?
ME: Well sort of, but not quite: You see in English there are rules: we have full stops, commas, brackets, hyphens, apostrophes and they all mean different things. Basically we all have a common agreement what a full stop means and your mother would obey those rules when understanding my letter.
Wife: So are you saying that JSON is a way of writing English to someone, but it has rules which both parties agree upon?
Me: Exactly! Except these rules are very specific. In prosaic English, the rules are pretty loose. The rules when writing in English are sort of like cage fighting: you can do whatever you want, except a few basics: no biting, or eye gouging. For example, if I wanted to tell your mother: about our family I can do it in a few different ways. Note the differences in each way.
Wife: ok
Me:
• 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.
Wife: Ok I get the picture. You can say the same thing many different ways in English. You can add a few words here and there. You can add a comma here and there and everyone will still understand.
Me: Exactly. Except in JSON, the rules are very restrictive. You can only communicate in a certain way. And you must follow those rules for someone else to understand it.
Wife: Why don’t they just use plain English instead?
Me: 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. Also 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, 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. The grammar police will be on you if you slip up with JSON. You can’t do that here because things simply will not work if you make mistakes.
Wife: So how do I write in Json?
Me: Well you basically are forced to communicate things using key-value pairs and using arrays.
Wife: What does that mean?
Me: Well how about we save that for a future post?
Summary
To sum up, JSON is basically a way of communicating data to someone, with very, very specific rules. Break those rules and nobody will understand what you are talking about.