Hello,
I have a problem with JSON response data that I don't how to model it
Here's an example
If the JSON data is something like this:
Code:
{
"users" : [
{
"name" : "tom",
"state" : "WA",
"id" : "cedf-c56f-18a4-4b1"
},
{
"name" : "steve",
"state" : "NY",
"id" : "ebb2-92bf-3062-7774"
},
{
"name" : "mike",
"state" : "MA",
"id" : "fb60-b34f-6dc8-aaf7"
},
.
.
.
]
}
I know that the model of that data will be something like this
Code:
Ext.define('Foo.model.User',{
extend: 'Ext.data.Model',
fields: [
{name: 'name' ,type: 'string'},
{name: 'state' ,type: 'string'},
{name: 'id' ,type: 'string'},
],
});
But what if the JSON response data are like these
Note: I don't have any control on the response
Code:
{
"users" : {
"cedf-c56f-18a4-4b1" : {
"name" : "tom",
"state" : "WA",
"id" : "cedf-c56f-18a4-4b1"
},
"ebb2-92bf-3062-7774" : {
"name" : "steve",
"state" : "NY",
"id" : "ebb2-92bf-3062-7774"
},
"fb60-b34f-6dc8-aaf7" : {
"name" : "mike",
"state" : "MA",
"id" : "fb60-b34f-6dc8-aaf7"
},
.
.
.
}
}
And of course the "cedf-c56f-18a4-4b1", "ebb2-92bf-3062-7774" ... etc, are totally unknown to me
How can I make the Model, Reader, ... etc for this data?
Thanks in advance
Edit: The field names that cause the problem (e.g. "cedf-c56f-18a4-4b1") are embedded in the data