On 05.09.2012 12:48, Marco Fleckinger wrote:
This long form will be RIGHT in the future { "labels":{ "de":{"value":"Foo","language":"de"}, "en":{"value":"Bar","language":"en"} } }
do you really want redundant information?
It's not redundant information, it's a lookup index for convenient access. Just like you would add indexes in a database.
And also this will be RIGHT { "labels":[ {"value":"Foo","language":"de"}, {"value":"Bar","language":"en"} ] }
Not easy browsable by using labels[lang] or labels.lang. Iterating through different labels is needed.
That'S why we are using the form with keys in the output. But we accept either form as input (associative as well as list) - for the input, the important thin is that the individual entries are complete and self-contained.
so why not using:
{ labels:[ de:{value:"Foo", source:whatever_de}, en:{value:"Bar", source:whatever_en} ] }
Here you can iterate through all items using their key and the value object:
for (key in labels) { console.log(labels[key]) }
Why wouldn't you be able to do just that with the form we suggest? In fact, in your example, the log would be missing the language code.#
The idea behind the format we are proposing is to use self-contained entries (records) for everything, and support named keys for convenience where possible.
-- daniel