Overview

What is JSON?

  • Stands for JavaScript Object Notation

  • A way to store information in an organized, easy-to-access manner

  • A popular way to send data from on web server (service) to another

  • Most data between services are sent as objects

  • JSON objects resemble a normal Javascript Object (it contains properties and values) but does not contain methods

{
  "id": 1,
  "name": "Scoobie Doo",
  "favoriteFood": "Scoobie Snacks"
}

JSON Guidelines

  • Property names must be double-quoted strings in order to be considered compliant JSON

  • Use meaningful property names

  • Access properties of a JSON object using dot notation or bracket notation


Example

  const avengers = {
    "members": [
      {
        "name": "Spider-Man",
        "alias": "Peter Parker"
      },
      {
        "name": "Black Widow",
        "alias": "Natasha Romanova"
      }
    ]
  }

  console.log(avengers.members[1].name)
  console.log(avengers["members"][0].alias)

JS Bin on jsbin.com