Sencha Touch Jsonpreader
-
25-10-2019 - |
题
使用sencha touch 2,正在尝试使用JSON代理渲染嵌套清单。 JSON看起来像
[
{
"start": "0"
},
{
"format": "json"
},
.......
{
"GetFolderListing": [
{
"folder": {
"total": 0,
"id": "Calendar",
"name": "Calendar",
"unread": 0,
}
},
{
"folder": {
"total": 0,
"id": "Contacts",
"name": "Contacts",
"unread": 0,
}
},
.......
我想将getFolderListing.folder.name用作我的商店看起来像显示的displayfiel
Ext.define('foo.store.FolderListing', {
extend: 'Ext.data.TreeStore',
require: ['foo.model.FolderListing'],
config: {
model: 'foo.model.FolderListing',
recursive: true,
proxy: {
type: 'jsonp',
url: 'http://localhost/?xx=yy&format=json',
callbackKey: "jsoncallback",
reader: {
type: 'json',
rootProperty: 'GetFolderListing',
record: 'folder'
}
}
}
});
现在我得到的只是一个错误的typeerror:无法读取未定义的属性“ id”
谁能提供有关如何解决此问题或更好地调试或如何进行自定义解析并将物品转回商店的见解?
谢谢
=========更新 - 为了使rootproperty在读者中工作,json必须是jsonobject,而不是json数组
{
"GetFolderListing": [
{
"folder": {
"total": 0,
"id": "Contacts",
"name": "Contacts",
"unread": 0,
"leaf": "true"
}
},
{
"folder": {
"total": 0,
"id": "Conversation Action Settings",
"name": "Conversation Action Settings",
"unread": 0,
"leaf": "true"
}
},
.......
解决方案
您的JSON看起来像个数组。错误消息意味着该代码试图访问未定义变量或属性的属性。
我的第一个猜测是,该数组类型JSON格式未正确配置读者。
不隶属于 StackOverflow