I would like to map a given array index into a property with RestKit (OM2). I have this JSON:
{
"id": "foo",
"position": [52.63, 11.37]
}
which I would like to map to this Object:
@interface NOSearchResult : NSObject
@property(retain) NSString* place_id;
@property(retain) NSNumber* latitude;
@property(retain) NSNumber* longitude;
@end
I can't figure out how to map values out of the position array in my JSON into properties of my objective-c class. The mapping looks like this so far:
RKObjectMapping* resultMapping = [RKObjectMapping mappingForClass:[NOSearchResult class]];
[resultMapping mapKeyPath:@"id" toAttribute:@"place_id"];
Now how can I add a mapping for the latitude/longitude? I tried various things, that don't work. e.g.:
[resultMapping mapKeyPath:@"position[0]" toAttribute:@"latitude"];
[resultMapping mapKeyPath:@"position.1" toAttribute:@"longitude"];
Is there a way to map position[0]
out of the JSON into latitude
in my object?