Before you go, check out these stories!

0
Hackernoon logoCoding 101: Who is Json? by@DataGeneralist

Coding 101: Who is Json?

Author profile picture

@DataGeneralistSteven Finkelstein

Data analytics generalist. I publish notes, lessons, and tools for data analytics and investing.

A.) Jason Voorhees (Friday the 13th)

B.) Jason Statham

C.) Jason Derulo

D.) The file type for machines.

While Voorhees, Statham, and Derulo all have their talents, both good and evil, I would propose that the best Json goes to the machine-readable file format. Json, or rather JSON, is an important acronym in the tech world. JSON stands for JavaScript Object Notation. It is frequently used by data professionals, software engineers, and folks in IT. If you have never written a piece of code, this will seem like a foreign language to you. Guess what? It is.

Let’s break it down.

{ JS: JavaScript }

JavaScript is a scripting or programming language that allows you to implement complex features on web pages (per Mozilla). This is one of the most popular programming languages used for constructing websites. Whether you are visiting Zillow.com or Gap.com , or almost any website, it is highly likely that the construction relies, to some extent, on JavaScript. How do I know that they use JavaScript?

Let’s take a look.

  1. Open up a new tab and go to Gap.com (see images below).
  2. Right click anywhere on the page and select, “Inspect Element” or “Inspect”, depending on your browser. This will open a new panel in the window from the bottom half.
  3. In this new panel, confirm that you are on the “Elements” or “Inspector” tab. Scroll up or down until you see the word, “text/javascript” or a file name that ends in “.js”.

One example of code is a line that reads the following:

<script type=”text/javascript” src=”/static_content/onesitecategory/components/mfe/sitewide-app/69.5e08e990.js? defer=”defer”.></script>

The above line calls one specific JavaScript file to run a set of code, or instructions. The instructions (i.e. JavaScript) change how the Gap homepage looks and feels when you interact with it.

{ ON: Object Notation }

Merriam-Webster defines notation as a system of characters, symbols, or abbreviated expressions used in an art or science or in mathematics or logic to express technical facts or quantities. One common notation is using x to represent an unknown value, or variable, in mathematics.

However, in this instance, humans designed JSON as a specific notation that can be easily interpreted by a machine. An apt comparison for notation that is easily human-readable would be a grocery list. The graphic below shows the transition of a typical grocery list from normal human notation into a JSON format.

In this graphic, the objects are the name of the list, the categories of grocery items, and the various items themselves. Each object is surrounded by curly brackets, while the items inside them are written as “key” : “value” pairs. You can try writing in a JSON format here.

{ How Can I Interpret JSON? }

Because JSON files are difficult for humans to interpret, programmers need to eventually convert the output into something more readable. If you don’t have any programming knowledge and need to interpret a JSON file, there are JSON viewers on the web. We can test one out with the grocery list in JSON format from the image above.

  1. Open a new tab for this JSON viewer (see images below).
  2. While in the “Text” tab, paste in the JSON code below:
    {“Grocery List”: {“Food”: { “Bread”: “1 loaf”, “Chips”: “2 bags” }, “Drinks”: {“Soda”: “2 12 packs”, “Water”: “1 case”}, “Other”: {“Paper Towels”: “4 rolls”, “Cups”: “30 plastic cups”}}}
  3. Click the “Viewer” tab
  4. Click the plus signs to keep opening up the different objects.

{ Why is JSON Important? }

Imagine trying to read a Harry Potter novel written in JSON format. Reading an entire chapter would probably take hours and it would give you a headache. This is comparable to the struggle that machines have with reading and interpreting our novels written in paragraph form, except I don’t think computers can have headaches. Regardless, a machine can read a JSON formatted file MUCH FASTER than data or text written in a human-readable format. Programmers refer to speed as performance. Programmers love it when their code has high performance (i.e. executes quickly).

Next time you hear someone mention JSON, it will no longer seem like a foreign language to you. No need to bite your pencil out of frustration. Think back to your grocery list. All JSON does is transform information into a different format. The new format allows machines to read the information quicker.

I’m sure you will perform well, too.

Sincerely,

~ The Data Generalist

Image Sources Unsplash

Previously published https://thedatageneralist.com/tech101-who-is-json/

Tags

Join Hacker Noon

Create your free account to unlock your custom reading experience.