WEEK: 9
Active: April 18th - April 24th
Work Due: April 25th @ 8:00AM

JSON data structures

Before we explore what APIs are and how to use them. You first need to be introduced to a new data structure; JSON or JavaScript Object Notation.

JSON is a standardized method for storing and transporting unordered collections of data. This data is stored through name:value pairs. Furthermore, the values in JSON data can be;

  • strings
  • numbers
  • booleans
  • arrays
  • or other nested JSON objects


JSON Objects, once in JavaScript (i.e. after being sent over from an API on a remote server), appear as JS objects. As such, they can be traversed and manipulated using standard JS object notation and techniques.

As an example, the following code creates a JS Object, which is also valid as JSON.

let obj = {
    "someName" : "someValue",
    "firstName" : "Michael",
    "aPerson" : {
        "firstName" : "Mr.",
        "lastName" : "Peanutbutter"
    },
    "anArray" : [
        "zero",
        "one",
        "two"
    ]
}

Once this object is binded to the variable obj, we can navigate through it and access it unique values.

The following example creates the same object as above, but also demonstrates how to access values within the object.

Readings on JSON


Previous section:
Next section: