PDA

View Full Version : Using JSON array as model input



DexterJS
24 Jun 2014, 10:29 AM
Hi,

I have JSON input from the server that is an array looking something like this:


[{
"setup": {
"id": "0001",
"part.a": {
"name": "A Name",
"key1": "value1",
"key2": "value2",
}
}
}, {
"setup": {
"id": "0001",
"part.b": {
"name": "B Name",
"key3": "value3",
"key4": "value4",
}
}
}]

So it is an array of elements, all of which are needed to display one page.
How could the model be defined to be able to read this? Would it be much easier if the array was wrapped in a root JSON object?

mitchellsimoens
16 Jul 2014, 9:44 AM
A model only reads a single object, not an array. So the data needs to be edited.

DexterJS
16 Jul 2014, 10:38 AM
Thanks. I added a single root key with the array as a value to fix the problem.

(By the way, for some reason, in the Chrome browser, the Sencha forum buttons appear in Chinese (I guess). In Safari, the text is in English. The browser is set to use English/UTF8 and all the other web sites and other Sencha pages appear with English buttons.)