Methods ¶
__init__()
Constructs a new, empty dictionary
__init__(dict, skip_invalid=False)
Constructs a new dictionary from the specified Python dictionary. If
skip_invalid
is True
, key/value pairs that refer to unsupported value
types are ignored. Otherwise, an exception is thrown when an invalid key
or value type is encountered.
__init__(string)
Constructs a new dictionary from the specified Python dictionary string representation.
__getitem__(key)
: object
Returns the value stored in the dicttionary for the given key
. If the
key isn’t found, throws a KeyError
exception.
__setitem__(key, value)
: object
Sets the value
of the specified key
.
asDictionary(recursive=True)
: dict
Returns a Python dictionary representation of this Dictionary
object. If
recursive
is True
then any nested Dictionary
values inside are also
recurisvely converted into Python dictionaries.
clear()
Clears all key/value pairs in the dictionary.
fromDictionary(dictionary, clear=True, skip_invalid=False)
Sets the key/value pairs in this dictionary to the ones in the native
Python dictionary
. Support values include integers, strings, floats,
dictionaries, or arrays of those data types.
If clear
is True then the existing keys in this dictionary are cleared
before copying keys from dictionary
, otherwise existing keys are kept
but may still be overwritten.
If skip_invalid
is True
then any keys that map to unsupport value types
are ignored, otherwise unsupport value types trigger an exception.
fromString(string, clear=True)
Sets the key/value pairs in this dictionary to the ones in the string representation of a standard Python dictionary.
If clear
is True then the existing keys in this dictionary are cleared
before copying keys from string
, otherwise existing keys are kept but
may still be overwritten.
get(key, default=None)
: object
Returns the value stored in the dictionary for the given key
. If the
key isn’t found, returns default
instead.
items()
: list
of tuple
Returns the list of key/value pairs in the dictionary, expressed as tuples.
keys()
: list
of str
Returns the list of keys in the dictionary.
pop(key, default=None)
: object
Removes and returns the value in the dictonary with the the given key
. If
the key isn’t found, returns default
instead.
set(key, value)
Sets the value of key
to the specified value
. The type of the value is
automatically determined as best as possible, but to explicitly set a
value of a particular type one of the other set*(
functions should be
used instead.
setBool(key, value)
Sets a boolean value with the specified key
.
setDict(key, value)
Sets a dictionary value with the specified key
.
setDictArray(key, value)
Sets a dictionary array value with the specified key
.
setFloat(key, value)
Sets a float value with the specified key
.
setFloatArray(key, value)
Sets a float array value with the specified key
.
setInt(key, value)
Sets an integer value with the specified key
.
setIntArray(key, value)
Sets an integer array value with the specified key
.
setString(key, value)
Sets a string value with the specified key
.
setStringArray(key, value)
Sets a string array value with the specified key
.
values()
: list
of object
Returns the list of values in the dictionary.