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