Reputation: 7746
I have JSON of following kind
{
"Client": {
"FirstName": "String",
"LastName": "String",
"Email": "String",
"Password": "String",
"PhoneNumber": "String",
"Token": "String"
},
"ErrorMessage": "String",
"FriendlyMessage": "String"
}
I know that while mapping if I specify a key path then RestKit matches fields from object specified, in this case Client
, to the code I am using for that is as follows
[responseMapping addAttributeMappingsFromDictionary:@{
@"FirstName": @"FirstName",
@"LastName": @"LastName",
@"Email": @"Email",
@"PhoneNumber": @"PhoneNumber",
@"Token": @"Token",
@"Password": @"Password",
@"ErrorMessage": @"ErrorMessage"}];
RKResponseDescriptor *responseDescriptor = [RKResponseDescriptor responseDescriptorWithMapping:responseMapping
method:RKRequestMethodPOST
pathPattern:nil
keyPath:@"Client"
statusCodes:[NSIndexSet indexSetWithIndex:200]];
But I have two additional fields to map which aren't under client object. How do I map ErrorMessage
and FriendlyMessage
fields ?
Upvotes: 0
Views: 64
Reputation: 119021
Generally you wouldn't want to map them into your client
object, you would want to map them into some other object. You would usually use a different object and response mapping, where the response mapping uses a different key path.
If for some reason you did want them in the same object then you could look at using the @metadata
/ @parent
to get to the parent (https://github.com/RestKit/RestKit/pull/1435).
Upvotes: 1