Hi,
On 07.09.2012 11:37, Denny Vrandečić wrote:
2012/9/5 Marco
Fleckinger<marco.fleckinger(a)gmail.com>om>:
On 05.09.2012 10:39, John Erling Blad 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?
The redundancy comes from the browsability that you discuss later.
This allows the object in the key-position to be completely
self-sustainable and can be passed around. The key is folded forward
to increase the browsability.
As Daniel wrote.
Also the keys do not explicitly say what they are
(language codes,
e.g., in this case). This makes the data format require more external
description.
Not part here, but part of the request where you may could ask for "by
language".
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.
so why not using:
{
labels:[
de:{value:"Foo", source:whatever_de},
en:{value:"Bar", source:whatever_en}
]
}
Because then the objects are not self-contained, as they do not say
which language they are.
Sorry, I did not know that this was your wish/requirement.
Here you can
iterate through all items using their key and the value object:
for (key in labels) {
console.log(labels[key])
}
So you can in the redundant version.
Exactly.
Marco