我正在努力尝试映射以下json响应:
{
"data":
{
"plans":
[
{
"planid":"10",
"plandescription":"foo",
"plantype":"2",
"planvalue":"30",
"status":"Active"
}
]
}
}
这就是我要做的事情:
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];
然而,对象没有被映射:\有什么问题?
答案 0 :(得分:0)
尝试将keyPath:@“data / plans”更改为keyPath:@“data.plans”