在ExtJS 4.1 JSON路径映射中转义冒号

时间:2013-06-07 09:54:51

标签: javascript json extjs escaping mapping

我想知道如何在JSON路径中逃避冒号。

以下是我的JSON字符串示例:

{
"succinctProperties": {
    "cmis:objectId": "35589dd4-647f-4a6d-884f-0575d8a93127",
    "cmis:name": "35589dd4-647f-4a6d-884f-0575d8a93127",
    "cmis:createdBy": "<unknown>",
    "cmis:lastModifiedBy": "Wed Jun 05 16:26:56 CEST 2013",
    "cmis:creationDate": 1370442416100,
    "cmis:lastModificationDate": 1370442416100,
    "cmis:changeToken": null,
    "cmis:baseTypeId": "cmis:document",
    "cmis:objectTypeId": "cmis:document",
    "cmis:isImmutable": false,
    "cmis:isLatestVersion": true,
    "cmis:isMajorVersion": true,
    "cmis:isLatestMajorVersion": true,
    "cmis:versionLabel": "35589dd4-647f-4a6d-884f-0575d8a93127",
    "cmis:versionSeriesId": "version_series_id",
    "cmis:isVersionSeriesCheckedOut": false,
    "cmis:versionSeriesCheckedOutBy": null,
    "cmis:versionSeriesCheckedOutId": null,
    "cmis:checkinComment": "",
    "cmis:contentStreamLength": 210028,
    "cmis:contentStreamMimeType": "application/octet-stream",
    "cmis:contentStreamFileName": "35589dd4-647f-4a6d-884f-0575d8a93127",
    "cmis:contentStreamId": null
}

}

我正在尝试使用我的ExtJS商店映射键作为模型:

Ext.define('MyApp.model.SearchDocumentModel', {
extend: 'Ext.data.Model',

fields: [{name:'OBJECT_ID',type:'string',mapping:'succinctProperties.cmis:objectId'},
         {name:'NAME',type:'string',mapping:'succinctProperties.cmis:name'}  
     ] 

});

我使用了几种转义方法,但没有一种方法可以使用。

当我加载它时,我得到了这个错误:

Uncaught SyntaxError: Unexpected token ILLEGAL

谢谢。

2 个答案:

答案 0 :(得分:0)

尝试将您的阅读器的useSimpleAccessors选项设置为true

答案 1 :(得分:0)

要解决此问题,我将此语法用于JSON路径:

<强> succinctProperties [ “CMIS:的ObjectID”]

Ext.define(MyApp.model.SearchDocumentModel', {
extend: 'Ext.data.Model',

fields: [{name:'OBJECT_ID',type:'string',mapping:'succinctProperties["cmis:objectId"]'},
         {name:'NAME',type:'string',mapping:'succinctProperties["cmis:name"]'}  
     ] });