JSON - Global

Provides methods to create JSON objects from a string, and to turn JSON objects into strings.

The JSON API has dynamic and static methods. You access the dynamic methods by creating a JSON object. To use the dynamic methods in a scoped application, add the global prefix when calling the constructor. You access the static methods by using the static JSON object.

This example creates a JSON object.
// obj is a JSON formatted object
var parser = new JSON(); // encode() and decode() are dynamic methods.
var str = parser.encode(obj);

The encode() and decode() methods are deprecated. Use the JavaScript JSON object instead.

This example creates a JSON object in a scoped script.
// obj is a JSON formatted object
var parser = new global.JSON();
var str = parser.encode(obj);
This example uses the static methods.
// obj is a JSON formatted object
var str =  JSON.stringify(obj);
// str is a string containing content to be turned into a JSON formatted object
var obj = JSON.parse(str);

In Helsinki and subsequent releases, the JavaScript ES5 native JSON object is used instead of the JSON static methods. If your script needs the old behavior, use the encode() and decode() methods.