Ad

Saturday, November 16, 2013

Basic JSON Format | JSON for Dummies

The basic JSON building block is a data attribute and value pair. It's a way to track data records in JavaScript.
{"attribute" : "value"}
e.g. {"name":"dilys"}

Every two building blocks are separated with a comma.
{"first name":"John","last name":"Doe"}

We can format the JSON better by displaying it hierarchically
{
"first name":"John",
"last name":"Doe"
}

To check if your JSON is correct you can use JSONLint auto checking
http://jsonlint.com/

To see more complex examples of JSON and also compounded, nested JSON objects
http://json.org/example.html

JSON is more useful than ever because most APIs like Google Map can provide data in JSON format. Key-value data stores used in nosql is also similar: a key value pair. There are subtle and important differences. Since this is an intro blog, I won't go into details. Consider this a JSON cheat sheet. 

[Updated] JSONLint is especially helpful when we can easily confuse JSON notation with key-value stores, i.e. missing double quotes. Just caught a data analysis book messing up JSON format slight today.

No comments:

Post a Comment

K mean clustering sklearn best practice - Udacity Machine Learning Nanodegree Unsupervised Learning

There are three key k means clustering parameters in sklearn that you will need to pay attention to: Number of centroids, aka center of c...