JSON - decode(String str)

Creates an object or primitive type from a JSON formatted string.

Note: This class is deprecated. Use the JavaScript JSON object instead.
Table 1. Parameters
Name Type Description
str String A JSON formatted string.
Table 2. Returns
Type Description
Object An object created from the specified string.
var str = ‘{“name":"George","lastname":"Washington”}’;
var parser = new JSON();
var obj = parser.decode(str);
gs.info(‘The first name is ’  + obj.name);

Output: The first name is George

To use in a scoped script.

var str = ‘{“name":"George","lastname":"Washington”}’;
var parser = new global.JSON();
var obj = parser.decode(str);
gs.info(‘The first name is ’  + obj.name);

Output: The first name is George