Loading [MathJax]/jax/output/HTML-CSS/fonts/TeX/fontdata.js

Receiving a JSON 

Most of the times we aren't going to request data to fetch a local file. Let's be honest, if that was the case we could have included an tag from the beginning directly to our HTML and define the src there. 

Most of the times we want to perform requests either to third-party libraries or to external public API's in order to get data from them. The most realistic scenario is that this data will come in a format of JSON.

JSON stands for JavaScript Object Notation (and has nothing to do with Jason Statham :-)). It has exactly the same structure as a javaScript array or a JS object (it depends most of the times is a combination of both). The key difference is that the keys of this JSON object are strings (surrounded by "double-quotes"), thus the whole JSON is a 'stringified' version of a JavaScript Object. 

That's because when exchanging data between a server and a client, this data that is being exchanged must be only a string and nothing else!

In order to be able to work with it, we must convert it to a normal JS Object. In the next chapter we are going to see how exactly this can be done when we are trying to fetch data from the openweathermap api, to bring weather information for a specific city, or place all over the world.   

You can have a look in the code above, if you want to understand what the structure of a JSON Object is.

Attention: If you don't convert the JSON object into a normal JS object (or array in this case), you will not be able to access it's data or to perform normal JS object (or array operations).  Bear in mind, that this is only a piece of string for now!

If you want to learn more about JSON files and documents in general, do it here!