JSON/Introduction

What is JSON?

edit

JSON is short for "JavaScript Object Notation. It is not a programming language, but a markup language, just like XML. It is made for quick lightweight data exchange from the server to the client, and is not to make apps, but to supplement them. Unlike XML, JSON is much more lightweight. It is based off JavaScript, but can be read by virtually any programming language that exists, since hundreds of libraries exist. A JSON file is simply a list of variables of data.

How this book will work

edit

Nice and short, this book will be divided into a few sections to go over each part. Due to the nature of JSON, it will be very easy to learn. At the end of this book will be a section with a few exercises. There shall be pictures of the code etc. throughout to show real examples of JSON code. Each page has a header, short introduction, the relevant pictures and information for the section, links to the previous and next sections, and links at the bottom for references and further reading. All source code written in this book will be formatted as so.

Note: Contributors must please follow this structure mentioned above.

What can JSON be used for?

edit

JSON is used mainly for web applications, to exchange quick bits of data in a single file. This is not limited to websites, but also online games, for example. It can also be used for other purposes, like for an application to store its settings in a lightweight file. Or, perhaps, it can be used by a game to store a player's data. All types of JavaScript variables are usable here, from integers to arrays.

How does JSON work?

edit

JSON data is stored in a file, which is left as is. It is not compiled into binary code, just left as is. This is the nature of any markup language, not just JSON. It is up the application to open the file, scan the text and pick out the data it needs, and change whatever it needs to change. A developer would use a 'parser library' to do the work of scanning the text and loading certain variables into memory for the application to use. Variables, such as integers are created here and stored in the file. JSON files end with ".json" and are stored wherever the application needs it to be.

Is JSON difficult?

edit

Absolutely not. JSON, for starters is human-readable, so it is easy to get the understanding of it quickly. Syntax is simple and based on JavaScript. It helps to know JavaScript, since JSON is JavaScript. It takes only a day to learn, really, even if you don't know JavaScript.

Are there any prerequisites?

edit

Yes. You need to actually know and understand a programming language, since JSON is only there to complement your application, not make it. You will need a code editor to continue, like Atom or Visual Studio Code, though any text editor like Notepad will do. You can download both Visual Studio Code and Atom for free. Finally, for whatever programming language you use, you need a parser library to continue.

References

edit
  1. Wikipedia - JSON[1]

Further reading

edit
  1. XML
  2. Markup language
  3. JavaScript
  1. [1]