method fromJSON

void fromJSON(stream encodedValues);

Argumente

Zurückgegebener Wert

This method creates the dictionary pairs from a JSON UTF-8 encoding that was similar to the stream returned from toJSON. The JSON string must start with "{" and end with "}". All the non-embedded values in the JSON encoding must be key/value pairs, otherwise method fails. All pairs are removed from the dictionary first.
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},
}
*/

var dictObj2 = shell.serviceManager.basics.dictionary;
dictObj2.fromJSON(jsonStream);
jsonStream.close();
/*fromJSON will remove all the elements first.
The result key/value pair of the dictionary is the following:
name      - Hello World
isVisible - 0
users     - john
          - tom
width     - 400
*/