By: Skillcrush

Category: Uncategorized

JSON stands for JavaScript Object Notation and it’s one common way to pass information from a database to a website.

JSON originated as a replacement for XML (eXtensible Markup Language) when web browsers need to talk to servers. It is based on JavaScript so web browsers can read it very quickly, but can be used by any programming language. JSON doesn’t dictate what data you share, but how you organize it.

Whenever you want to describe something in JSON you start by creating an object. You do this by opening a curly bracket { and closing it }. Any of the information you put in between those two brackets is information about that object.

You then give the object a series of properties. Each property has a name and a value, like so:

name: value,
name2: value2

The names and values can be anything. JSON doesn’t dictate what you say, just how you say it.

Imagine if you asked me for information about the object Skillcrush and you asked that I format my response in JSON. I would tell you my name, email, address, phone number, and whether the company is publicly traded like so:

"name": "Skillcrush",
"email": "hello@skillcrush.com",
"number": 34,
"street": "West 27th Street",
"city": "New York",
"state": "New York",
"zip_code": "10001"
"phone_number": "212 889 9199",
"publicly_traded": false,
"ticker_symbol": null

When you put data into JSON you have four different data types that you can use.

You can include a string (some text which you place in between quotes like “Skillcrush”), you can provide a number (like 34), you can provide a boolean value (true or false), an array (a collection of other JSON data types, for instance my address has a few different values), or you can just say null (like “ticker_symbol”) meaning nothing.

Many social media APIs use JSON as their way to provide you with access to their data. You will remember from our post about API‘s that Facebook’s API sends you data back in JSON (take a peek), as does Twitter.

Now Try This

  1. Take a look at Skillcrush’s last two tweets on Twitter on Twitter’s API
  2. Check out our stats:
    We are not verified (“verified”:false)
    We have tweeted 945 times (“statuses_count”:945)
    We have 1139 followers (“followers_count”:1139)
    And have been listed 40 times (“listed_count”:40)
  3. Now follow us!

Cocktail Party Fact

CouchDB is an entire database that allows you to store all your data in JSON documents instead of using database tables like MySQL.

When the developers of the app Instinct, a web app that helps you learn to play guitar, they chose to use CouchDB because it gave them much more flexibility than traditional relational databases with their columns and rows. Turns out it’s much easier to change the values of your JSON object than it is to reorganize a whole database.


Want more articles like this?

Sign up to get the most recent tech news, tips and career advice.