What's the best way to get server data into a store if the response format is different from one web service to another? Example:
user/1 returns
Code:
{response:
{id:1, name:'Charles'}
}
...but favorites/2 returns
Code:
{data:{
person:{id:2, name:'Snoopy'},
favorites:[
{id:1, name:'Charles'},
{id:3, name:'Woodstock'}
]
}}
...and my Person model has a convert function like
Code:
Ext.define('Person',{
extend:'Ext.data.Model',
config:{
fields:[
{
name:'name',
type:'string',
convert:function(value,record){
//If the name is Charles, change it to Blockhead
if(value == 'Charles'){return 'Blockhead';}
else{return value;}
}
}
]
}
})
In other words, how can I ensure that Charles gets stored properly regardless of the source web service?