JSON

What Is JSON?

JSON is short for JavaScript Object Notation, and is a way to store information in an organized, easy-to-access manner. In a nutshell, it gives us a human-readable collection of data that we can access in a really logical manner.

Storing JSON Data

var jason = { age : 24, hometown : 'Missoula, MT', gender : male};

document.write(jason.age);document.write(jason.gender);

Storing JSON Data in Arrays

var family = [{ name : Jason, age : 24, gender : male},{ name : Kyle, age : 21, gender : male}];

document.write(family[1].name);document.write(family[0].age);

Nesting JSON Data

var family = { jason : { name : 'Jason Lengstorf', age : 24, gender : male }, kyle : { name : 'Kyle Lengstorf', age : 21, gender : male }}

document.write(family.jason.name);document.write(family.kyle.age);document.write(family.jason.gender);

Related Posts

MooTools - JSON