JSON for Beginners: Understanding its Awesomeness versus SOAP messages

What does JSON stand for and where is it from?

JSON stands for JavaScript Object Notation. It was created out of a need for a lightweight transportation format. JSON provided this lightweight data-interchange format. It is based on a subset of JavaScript Programming Language in the Standard ECMA-262 3rd Edition created back in 1999.

Why use JSON? What about other formats like a SOAP?

One of the biggest reasons for this lightweight format started when there was a need to transport data to mobile devices. Specifically smart phones. 3G LTE, and even 4G are not as  fast as 20- 50 Mbps on a wired machine. For this reason, the smaller the footprint, the better the user experience.  JSON uses a syntax with less requirements for attributes and opening and closing an object or list of objects. SOAP is the transport format used in the WCF / RPC paradigm. Whether you agree on REST or RPC, a SOAP message is a subset of XML. This makes a little more bloated with open and close tags such as <> and </>. An example of SOAP looks like this:

As you can see, there is quite a lot going on here. Believe it or not, all this data being returned is only being used to return to the caller that there is a PriceReponse object with the property of Price. Now, lets see the same example of a single object in in JSON.

And here is a JSON array:

As you can see, much less characters to create the same content. The JSON array actually contains more objects thank the SOAP message.

JSON format and how to construct them

JSON is interesting, it is easy to read for both a human and a machine, but hard (at least for me) to remember the syntax.

When dealing with the JSON format, there are 3 layers.

  1. values
  2. objects
  3. arrays

Name Value pair Relations to JSON

  • value– This is the container that holds the actual content (not name). This can be several different types. Since JSON is part of a subset of JavaScript, it is dynamic and the type if interpreted at run-time.Here is a diagram of what a value content types.
json value types
JSON value types: http://www.json.org/
  • object – The value is always accompanied by a name. This is often called a name/value pair because the name is how you find the item (you can look at it as the index and often it is). The value itself is the data you want to retrieve when you find the name.  The syntax for an object uses squiggles and colons.

Above is an example of an object that has 2 properties, name and Age. The name is the index and the part after the : is the value. You will also notice that the age value is not surrounded by quotes. This is because it will be inferred as an integer and is still a valid format.

JSON object example
JSON object example: http://www.json.org/

JSON arrays

  • array – An array is like any other language. It acts as a container for multiple objects. The beauty of the array format is that it is almost identical to an object. Which makes sense. an object is a list of parameters, an array is a list of objects.. DUHHH :).

Below is an example of a very basic array with just string values. This is great for small data, but gets hard to query and understand after a handful of records.

JSON basic array
JSON basic array


The next example is a little more real world like. It is an array that contains 2 objects. each object contains an age and name property. The brackets at the start and end dictates it is an array. You can also separate arrays by commas.


I think that’s enough information about JSON for now. If anyone has any other questions or would like a post with more details, feel free to leave something below.

Don’t forget to subscribe!!


Leave a Reply

Your email address will not be published. Required fields are marked *