我有下面的json需要顯示在列表(locations數組)中。我可以通過rootProperty:response.data.locations獲取位置數組,但我如何獲得成功,徽標和backgroundpicture。任何建議都會有幫助。JSON解析問題sencha touch 2
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": "[email protected]",
"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": "[email protected]",
"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");
}
}
}
});
什麼是你的'商店'或'模型'rootProperty設置? – AlexC
在我的問題 – kush