Thursday, 29 August 2013

RestKit: How to preprocess JSON value before mapping

RestKit: How to preprocess JSON value before mapping

Currently I am using the following JSON format which is a snippet from
SharePoint REST service:
{results:[
{uri:"https://site.com/_api/Web/Lists(guid'43963c38-4d1c-4734-8b2d-22dc0b92908c')"},
{uri:"https://site.com/_api/Web/Lists(guid'5363c738-7d9d-9774-6b2d-52dc0b93903d')"}]
}
And I have the following object mapping:
RKEntityMapping *listMapping = [RKEntityMapping
mappingForEntityForName:@"SPList"
inManagedObjectStore:managedObjectStore];
[listMapping addAttributeMappingsFromDictionary:@{
@"uri": @"guid"}];
listMapping.identificationAttributes = @[@"guid"];
However, before saving to guid, I would like to add logic to retrieve only
the guid part from uri before saving, so only
"43963c38-4d1c-4734-8b2d-22dc0b92908c" is stored in guid field. I don't
know where to add that logic, could anyone help me?

No comments:

Post a Comment