PDA

View Full Version : Arrays in JSON



mcaple
8 May 2012, 6:12 PM
Hi,
If I have the following JSON data

Ext.data.JsonP.callback1([{"mobQuoteAmount":[{"amount":[0,27.95,0,0]},{"amount":[0,0,0,0]},{"amount":[0,0,0,0]}],"productid":"1"}]);

could someone help me to come up with the model for this scenario. At the moment I have tried



Ext.define('MyApp.model.mobQuoteAmount', {
extend: 'Ext.data.Model',
config: {
fields: [
{
defaultValue: [
[
0,
0,
0,
0
],
[
0,
0,
0,
0
],
[
0,
0,
0,
0
]
],
name: 'amount'
},
{
name: 'productid'
}
]
}
});


and productid gets populated but amount never. The thing I do not understand is that there is an object labeled mobQuoteAmount and it has an attribute named productid but I do not know how to define a placeholder for 'amount' as the values in the array have no label, if that makes sense. I have also tried using a 'HasMany' association but it still comes down to an anoymous value in an array.

Many thanks.