[
{
"@aircraftId": "8a8aa3943e3ee05c013e3f59930d06df",
"tailNumber": "QA14",
"stockNumberCode": "ST-AC-B5S"
},
{
"@aircraftId": "8a8aa3943e62f9de013e63433f790034",
"tailNumber": "QACU2",
"stockNumberCode": "QA-ST-CU2"
},
{
"@aircraftId": "8a8aa3943e62f9de013e63455362004b",
"tailNumber": "453201",
"stockNumberCode": "SN453201"
},
{
"@aircraftId": "8a8aa3943e3ee05c013e3eea2db3000d",
"tailNumber": "HR455",
"stockNumberCode": "HR ST THUR"
},
{
"@aircraftId": "8a8aa3943e62f9de013e6356190601a2",
"tailNumber": "N171",
"stockNumberCode": "E171"
},
{
"@aircraftId": "8a8a95ca38104bbb01381fcaf8e43831",
"tailNumber": "N760CP",
"stockNumberCode": "E170"
},
{
"@aircraftId": "8a8aa3943e3ee05c013e3f1896bb065e",
"tailNumber": "123",
"stockNumberCode": "ST-12345"
},
{
"@aircraftId": "8a8aa3943e3ee05c013e405d25f70846",
"tailNumber": "143",
"stockNumberCode": "MPR"
},
{
"@aircraftId": "8a9e82af3eef9d3a013ef0805ca30022",
"tailNumber": "ARN 0529",
"stockNumberCode": "ACS 0529"
},
{
"@aircraftId": "8a9e82af3ef3d12a013ef41de5590067",
"tailNumber": "ARN 0530",
"stockNumberCode": "ACS 0530"
},
{
"@aircraftId": "8a9e82af3ef3d12a013ef41c976e0058",
"tailNumber": "ARN 30",
"stockNumberCode": "ACS 30"
}
]
这是我的休息服务的json respone这里是我的模型和商店
Ext.define('FCELB.store.AircraftStore', {
extend: 'Ext.data.Store',
config: {
model: 'FCELB.model.AircraftModel',
storeId: 'aircraftstore',
autoLoad:false,
proxy: {
type: 'jsonp',
method:'Get',
url: 'http://10.30.2.139:8080/xl/api/1/aircrafts/json',
reader: {
type: 'json'
},
headers: {
'Accept':'application/json'
} ,
listeners: {
load : function(store, records, successful, operation, eOpts) {
console.log('Aircrafts load..');
}
}
}
}
});
你能不能请我在我的商店课程中遗漏了一些东西我能成功解析似乎我不是用json阅读来获取但是在回调中我得到的结果对象长度为零
这是我对json的商店调用
var store = Ext.create('FCELB.store.AircraftStore');
//store.load();
store.load({
callback: function (records, operation, success) {
console.log('rest service called' + records);
},
failure: function (record, operation) {
console.log('invode failed returend records' + record);
},
success: function (record, operation) {
console.log('in success function' + record);
}
});
以下是我对上述json格式的模态定义
Ext.define('FCELB.model.AircraftModel', {
extend: 'Ext.data.Model',
config: {
fields: [
{name: 'tailNumber', mapping:'tailNumber' }
]
//hasMany:'aircraft'
}
});
答案 0 :(得分:1)
试试这个...... 在你的商店
... 读者:{ 输入:'json', root:'items' }, ...
关于你的json响应,把它改成......
{
"items": [
{
"@aircraftId": "8a8aa3943e3ee05c013e3f59930d06df",
"tailNumber": "QA14",
"stockNumberCode": "ST-AC-B5S"
},
{
"@aircraftId": "8a8aa3943e62f9de013e63433f790034",
"tailNumber": "QACU2",
"stockNumberCode": "QA-ST-CU2"
},
...
]
}