JSON - encode(Object jsonObject)

Creates a string from a JSON object.

Note: This class is deprecated. Use the JavaScript JSON object instead.
Table 1. Parameters
Name Type Description
jsonObject Object The JSON object to be turned into a string.
Table 2. Returns
Type Description
String A JSON formatted string.
var obj = {“name":"George","lastname":"Washington"};
var parser = new JSON();
var str = parser.encode(obj);
gs.info(‘The object ’  + str);

Output: The object {"lastname":"Washington","name":"George"}

To use in a scoped script.

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