Index
Overview


JSON (JavaScript Object Notation) is format used for data interchange that is human friendly.

The JSON format melds perfectly into how we think as object coders.

Examples


Basic
Similar to JavaScript plain objects
{
	"name": "Fluffy",
	"weight": 25,
	"prefersIndoor": true
}
Child (Nested) Objects
We can nest objects (children) as much as we need to.

Here we have a child object "pet".
{
	"address": "100 Oak Street",
	"pet": {
		"name": "Fluffy",
		"weight": 25,
		"prefersIndoor": true
	},
	"phone": "123 123-1234",
}
Collections
And we can have collections of objects.

Here we have a collection "pets" of two objects"
{
	"address": "100 Oak Street",
	"pets": [
		{
		"name": "Fluffy",
		"weight": 25,
		"prefersIndoor": true
		},
		{
		"name": "Muffy",
		"weight": 15,
		"prefersIndoor": false
		}
	],
	"phone": "123 123-1234",
}


JavaScript stringify and parse


The methods "stringify" and "parse" are big hitters in the js-json world.

They are simple to use as shown below.

stringify
Convert an object "myObject" into a JSON string.

We are encoding/deflating the real object into a string.
const jsonString = JSON.stringify(myObject);
parse
Convert a a JSON string into an object "myObject".

We are decoding/inflating the string into a real object.
const myObject = JSON.parse(jsonString);