具有各种数据类型的JSON响应
我有一个类似这样的JSON响应具有各种数据类型的JSON响应,json,extjs,Json,Extjs,我有一个类似这样的JSON响应 "{"total":1,"userBeanId":300,"list":[{"errors":[],"success":true,"liferayUserId":31503,"companyId":null,"groupId":null,"locale":null,"status":null,"liferayUserGroupId":null,"idProvider":null,"idClient":null,"userType":4,"userId":200,"
"{"total":1,"userBeanId":300,"list":[{"errors":[],"success":true,"liferayUserId":31503,"companyId":null,"groupId":null,"locale":null,"status":null,"liferayUserGroupId":null,"idProvider":null,"idClient":null,"userType":4,"userId":200,"email":"xpto@gmail.com","telefone":"999999999","nome":"MYNAME","role":"MY_ROLE","perfil":"Administrator","lastName":null}],"success":true}"
"Ext.define('
MYPROJECT.store.Profiles', {
extend: 'Ext.data.Store',
model: 'MYPROJECT.model.Profile',
autoLoad: true,
pageSize: 10,
remoteSort: true,
remoteFilter: true,
proxy: {
type: 'ajax',
api: {
read: '/delegate/rlapi-common/profile/list'
},
enablePaging: true,
reader: {
type: 'json',
root: 'list',
successProperty: 'success'
}
}
});"
我有一个可以读取列表内容的商店,就像这样
"{"total":1,"userBeanId":300,"list":[{"errors":[],"success":true,"liferayUserId":31503,"companyId":null,"groupId":null,"locale":null,"status":null,"liferayUserGroupId":null,"idProvider":null,"idClient":null,"userType":4,"userId":200,"email":"xpto@gmail.com","telefone":"999999999","nome":"MYNAME","role":"MY_ROLE","perfil":"Administrator","lastName":null}],"success":true}"
"Ext.define('
MYPROJECT.store.Profiles', {
extend: 'Ext.data.Store',
model: 'MYPROJECT.model.Profile',
autoLoad: true,
pageSize: 10,
remoteSort: true,
remoteFilter: true,
proxy: {
type: 'ajax',
api: {
read: '/delegate/rlapi-common/profile/list'
},
enablePaging: true,
reader: {
type: 'json',
root: 'list',
successProperty: 'success'
}
}
});"
并且商店成功地“读取”了列表。但是,我也希望能够访问“userBeanId”字段。是否有任何方法可以通过此存储访问它(通过将根目录更改为更高级别的内容)?这让我感到困惑,因为商店“映射”到一个模型,而userBeanId不适合这个模型 型号:
Ext.define('MYPROJECT.model.Profile', {
extend: 'Ext.data.Model',
fields: [
'userId',
'nome',
'telefone',
'email',
'role',
'perfil'
],
});
您可以访问
store.proxy.reader.rawData
以获取最近加载的JSON。正如您所建议的,作为模型的一部分是没有意义的,但是您可以通过阅读器阅读额外的元信息。“,我希望能够访问“userBeanId”字段,以及“从何处”,另外,您可以显示您的模型以及使用模型更新的帖子谢谢。对于有相同疑问的人,有关更多详细信息,请参阅。在我的例子中,var userBeanId=store.proxy.reader.rawData.userBeanId;