| Page Views: 349

JSON Tutorial

This is a JSON tutorial. We cover JSON theoretically from a computer science point of view.

Introduction to JSON?

JSON stands for JavaScript Object Notation and is a language-independent data format that expresses JSON objects as human-readable lists of properties(name-value pairs).

It is a data format derived from the literals of the JavaScript programming language.

You can also think of it as a textual representation defined by a small set of governing rules in which data is structured.

As a subset of the JavaScript language JSON does not possess any additional features that the JavaScript language itself does not already possess.

However although JSON is a subset of a programming language, it itself is not a programming language but, in fact, is a data interchange format.

JSON's main use is as the data format wherever the exchange of data occurs. And this can occur between both browser and server and even server to server.

JSON was created by Douglas Crockford. However Crockford himself admits that he is not the first to have realized the data format, but he did provide it with a name and a formalized grammar within RFC 4627.

The RFC 4627 formalization was written in 2006. It marked the inrtoduction of JSON to the world. JSON was registered as an Internet media type application/json and the file extension is .json.

Today JSON is the most popular data exchange format for the web. One of the reasons is its grammatical simplicity,which allows for JSON to be highly interoperable.

The JSON data format expresses both objects and arrays in the form of their literal.It uses literals to capture all JavaScript values, except for the Date object, as it lacks a literal form.

JSON is much lighter than XML and that has been key to it's soaring popularity in more than decade since it's creation. XML is modeled after SGML, a document format. This makes XML possess qualities that make it very verbose, which is not ideal for data transmission.

JSON structure

The JSON specification states that data can be structured in either of the two following compositions:

  1. A collection of name/value pairs
  2. An ordered list of values

(a). Collection

A collection begins with the use of the opening brace {, and ends with the use of the closing brace } and it:

  1. can remain devoid of any string/value pairs.
  2. can be that of a single string/value pair.
  3. allows for a scenario where after a single string/value pair is supplied, the collection needn’t end but, rather, allow for any number of string/value pairs, before reaching the end. Each string/value pair possessed by the collection must be delimited or separated from one another by way of a comma ,.

String/value is equivalent to key/value pairs, with the exception that said keys must be provided as strings.

(b). Ordered List of Values

An ordered list begins with the use of the open bracket [ and ends with the use of the close bracket ].

For the ordered list of values:

  1. our list can remain devoid of any value(s).
  2. our ordered list can possess a singular value.
  3. the length of our list can possess any number of values, which must be delimited, that is, separated, with the use of a comma ,.

In JSON the characters [ ] and { } represent an array and an object respectively. These come directly from the JavaScript language itself where these characters do represent the Object and Array.

Common Uses of JSON

JSON is commonly used in the following areas:

  1. In asynchronous browser/server communication via AJAJ.
  2. With NoSQL database management systems such as MongoDb and CouchDb.
  3. With apps from social media web sites such as Twitter, Facebook, LinkedIn,and Flickr, Google Maps API etc

How do You Feel after reading this?

According to scientists, we humans have 8 primary innate emotions: joy, acceptance, fear, surprise, sadness, disgust, anger, and anticipation. Feel free to tell us how you feel about this article using these emotes or via the comment section.

About Me.

After completing his Software Engineering bachelors program, Oclemy(Clement Ochieng) these days is a man of two lives. At day he works for a startup in Nairobi, Kenya. At night he works tirelessly on building ProgrammingWizards TV, a tv channel for student coders and this website to help share the source code. In between he practices Meditation and Self actualization to help him keep balance. He also likes going for long solo walks to connect more with nature.


What do You Think

Previous Post Next Post