Dictionary Design

A dictionary is basically an array of key-value pairs ( see http://en.wikipedia.org/wiki/Associative_array ). Every key in a given scope must be unique. Each value may itself be a dictionary or other type. Max 5 is based on a dictionary type which can be serialized in the JSON format. The JSON format is convenient for representing this kind of structure, so it will be used here as well.

Here is an example of a simple dictionary:

{
    "messageName" : "drive",
    "messageValue" : 0.5
}

Here is a dictionary embedding another dictionary (similar to the one above) inside itself:

{
    "graphMessage" : {
        "name" : "drive",
        "value" : 0.5
    }
}

If we wanted to group together multiples of "graphMessage" into a bundle then they must all have unique names. That is not very convenient, so we could instead implement the above with the key "graphMessages". This "graphMessages" would then have as its value an array of dictionaries rather than a single dictionary:

{
    "graphMessages" : [
        {
            "name" : "drive",
            "value" : 0.5
        },
        {
            "name" : "bypass",
            "value" : 0
        }
    ]
}

Implementation

For speed we can base the implementation on TTHash from the Foundation. TTHash maps keys to TTValue objects. TTValue object can themselves then contain other objects.

See Also