When the array contains an element type that is not supported by this method, it returns the EE_INVALID_PARAM error.
var arrayObj = shell.serviceManager.basics.array;
arrayObj.addValue(42);
arrayObj.addValue("Hello World");
var users = shell.serviceManager.basics.array;
var keyPair = shell.serviceManager.basics.dictionary;
users.addValue("john");
users.addValue("tom");
keyPair.setValueForKey(users, "brother");
arrayObj.addValue(users);
arrayObj.addValue(keyPair);
arrayObj.addValue(false);
var jsonStream = shell.serviceManager.basics.memoryStream;
arrayObj.toJSON(jsonStream);
jsonStream.close();
/*
The resulting JSON in the stream will look like this:
[
42,
"Hello World",
["john", "tom",]
{"brother":["john", "tom"]},
"false"
]
*/