Iphone 使用RestKit解析嵌套的动态JSON
我正试图用RESTKIT解析以下JSON 并给出了相应的实现方法Iphone 使用RestKit解析嵌套的动态JSON,iphone,objective-c,ios,restkit,Iphone,Objective C,Ios,Restkit,我正试图用RESTKIT解析以下JSON 并给出了相应的实现方法 + (RKObjectMapping *) getObjectMapping { RKObjectMapping *objectMapping = [RKObjectMapping mappingForClass:[ImageCollections class]]; [objectMapping mapKeyPath:@"menu_url" toAttribute:@"ignore"]; objectMap
+ (RKObjectMapping *) getObjectMapping
{
RKObjectMapping *objectMapping = [RKObjectMapping mappingForClass:[ImageCollections class]];
[objectMapping mapKeyPath:@"menu_url" toAttribute:@"ignore"];
objectMapping.forceCollectionMapping = YES;
[objectMapping mapKeyOfNestedDictionaryToAttribute:@"keyTerm"];
[objectMapping mapKeyPath:@"(keyTerm).page" toRelationship:@"menus" withMapping:[ImageUrl getObjectMapping]];
return objectMapping;
}
类似地,ImageUrl类的对象映射是
+ (RKObjectMapping *) getObjectMapping
{
RKObjectMapping *objectMapping = [RKObjectMapping mappingForClass:[ImageUrl class]];
[objectMapping mapKeyPath:@"url" toAttribute:@"url"];
[objectMapping mapKeyPath:@"thumb_url" toAttribute:@"thumbUrl"];
return objectMapping;
}
但我有个例外
*** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ valueForUndefinedKey:]: this class is not key value coding-compliant for the key page.'
***由于未捕获的异常“NSUnknownKeyException”而终止应用程序,原因:“[valueForUndefinedKey:]:此类与密钥页的键值编码不兼容。”
请帮助..评估页键路径时所依据的值是什么?您是否尝试过使用单元测试来执行映射
+ (RKObjectMapping *) getObjectMapping
{
RKObjectMapping *objectMapping = [RKObjectMapping mappingForClass:[ImageUrl class]];
[objectMapping mapKeyPath:@"url" toAttribute:@"url"];
[objectMapping mapKeyPath:@"thumb_url" toAttribute:@"thumbUrl"];
return objectMapping;
}
*** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ valueForUndefinedKey:]: this class is not key value coding-compliant for the key page.'