我是 RestKit 的新手。有人可以帮我做地图吗?我有 JSON,我需要从 JSON 读取和保存数据。我该怎么做?
{"data": {
"viewer": {
"themes": {
"edges": [
{
"node": {
"id": "61c39",
"name": "ff"
}
}
{
"node": {
"id": "dd95af4b-"",
"name": "growth",
}
}
]
}
}
}
}
这是我的映射代码的一部分:
// Defines mapping for DefaultThemes
RKEntityMapping *mappingDefaultTheme = [RKEntityMapping mappingForEntityForName:@"DefaultThemeData"
inManagedObjectStore:self.managedObjectStore];
mappingDefaultTheme.identificationAttributes = @[@"themeId"];
[mappingDefaultTheme addAttributeMappingsFromDictionary:@{ @"node.id" : @"themeId", @"node.name" : @"name"}];
RKResponseDescriptor *themeDefaultListResponseDescriptor = [RKResponseDescriptor responseDescriptorWithMapping:mappingDefaultTheme
method:RKRequestMethodGET
pathPattern:@"graphql"
keyPath:@"edges.node"
statusCodes:RKStatusCodeIndexSetForClass(RKStatusCodeClassSuccessful)];
运行应用程序时出现错误:
Error: No mappable object representations were found at the key paths searched.
所以我需要知道,我应该如何进行数据映射?