PDA

View Full Version : Mapping a JSON message with colon in key/name



Emowpy
6 Jun 2013, 11:16 PM
Hi,

I would like to know if there's a way to map a JSON message with colon ":" in keys. Here's an example on my json message:



{
"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
}
}


And here's the code I'm using for mapping (which is not working) :



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


fields: [{name:'OBJECTID',type:'string',mapping:'succinctProperties.cmis:objectId'},
{name:'NAME',type:'string',mapping:'succinctProperties.cmis:name'}
{name:'BASETYPEID',type:'string',mapping:'succinctProperties.cmis:baseTypeId'}
]
});


I used several escaping methods but none of them works.

skirtle
7 Jun 2013, 7:23 AM
Try:


{name: 'OBJECTID', type: 'string', mapping: 'succinctProperties["cmis:objectId"]'}

Emowpy
9 Jun 2013, 11:14 PM
Already tried it and it works. I found it in the Ext.data.Field source code.

Thank you for your help. :)