sapo/Ink.js — pull request #6 by fabiosantoscode (2013-07-31 14:30:26+00:00)
Title: Adding Ink.Util.Json

Ink.Util.Json is a static module providing methods for serializing and parsing the JSON format.

Ink.requireModules(['Ink.Util.Json_1'], function (Json) {
var obj = {
key1: 'value1',
key2: 'value2',
keyArray: ['arrayValue1', 'arrayValue2', 'arrayValue3']
};
Json.stringify(obj); // The above object as a JSON string

var source = '{"key": "value", "array": [true, null, false]}';
Json.parse(source); // The above JSON string as an object
});

The API is similar to the standard JSON API present in modern browsers, speaking of which, when the `JSON` object is present, it is used instead of this module's parse/stringify code.