我有以下需要显示在列表(位置数组)中的 json。我可以使用rootProperty 获取位置数组:response.data.locations但我如何获得成功、徽标和背景图片。任何建议都会有所帮助。
Ext.data.JsonP.callback1(
{
"response": {
"success": true,
"data": {
"logo": "http:\\/\\/www.websiteurl.nl\\/Images\\/logo.jpg",
"backgroundpicture": "http:\\/\\/www.websiteurl.nl\\/Images\\/logo.jpg",
"locations": [
{
"id": "47",
"name": " 's-Gravenzande (De Carlton)",
"street": "Naaldwijkseweg",
"number": "257",
"zipcode": "2691 PV",
"city": "'s Gravenzande",
"province": "9",
"phone": "0174-412997",
"email": "info@websiteurl.nl",
"kvk": "27210224",
"lat": "51.988593",
"longitude": "4.188087",
"slug": "-sGravenzande-De-Carlton",
"website": "http:\\/\\/www.websiteurl.nl",
"logo": null,
"backgroundpicture": null
},
{
"id": "1",
"name": "Achterberg",
"street": "Weteringsteeg",
"number": "12",
"zipcode": "3911 VN",
"city": "Achterberg",
"province": "7",
"phone": "0317-613643",
"email": "info@websiteurl.nl",
"kvk": "30093218",
"lat": "51.976316",
"longitude": "5.601611",
"slug": "-Achterberg",
"website": "http:\\/\\/www.websiteurl.nl",
"logo": null,
"backgroundpicture": null
}
]
}
}
}
);
如果我在我的商店中添加一个监听器然后记录这些东西然后我会得到这些值但我的意思是我如何解析这个并将它存储在我的商店中
Ext.define("app.store.LocationStore",{
extend:'Ext.data.Store',
id: 'locationStore',
requires: 'Ext.data.proxy.JsonP',
config:{
autoLoad: 'true',
model:'app.model.LocationModel',
proxy:
{
type:'jsonp',
url:'http://www.websiteurl.nl/API/',
limitParam: false,
pageParam: false,
startParam: false,
extraParams:
{
method:'general',
token: '123456'
},
reader:{
type:'json',
successProperty: 'success',
rootProperty: 'response.data.locations'
}
},
listeners:{
load : function()
{console.log(this.getProxy().getReader().rawData.response.data.backgroundpicture);
console.log(this.getProxy().getReader().rawData.response.data.logo);
console.log(this.getProxy().getReader().rawData.response.success);
console.log("location store loaded");
}
}
}
});