0

I'm struggling trying to map the following json response:

{
 "data":
       {
        "plans":
          [
           {
             "planid":"10",
             "plandescription":"foo",
             "plantype":"2",
             "planvalue":"30",
             "status":"Active"
           }
         ]
       }
}

This is what I'm trying to do:

RKObjectMapping *planMapping = [RKObjectMapping mappingForClass:[Plans class]];
[planMapping addAttributeMappingsFromDictionary:@{
 @"planid": @"planId",
 @"plandescription": @"planDescription",
 @"plantype": @"planType",
 @"planvalue": @"planValue",
 @"status" : @"status"
 }];

RKResponseDescriptor *planResponseDescriptor = [RKResponseDescriptor responseDescriptorWithMapping:planMapping pathPattern:nil keyPath:@"data/plans" statusCodes:RKStatusCodeIndexSetForClass(RKStatusCodeClassSuccessful)];
[objectManager addResponseDescriptor:planResponseDescriptor];

Yet the object doesn't get mapped :\ What is wrong?

Rizon
  • 1,516
  • 4
  • 25
  • 45

1 Answers1

0

Try changing keyPath:@"data/plans" to keyPath:@"data.plans"

Christian
  • 584
  • 6
  • 6