我完全被困在试图映射这个 JSON 数据:
{
"All_Data": [
{
"TANTENNE": [
{"ID": 2068, "KIND": "PARABOLE"},
{"ID": 2069, "KIND": "ANTENNE TNT HERTZIENNE"},
{"ID": 2070, "KIND": "ANTENNE COLLECTIVE"},
{"ID": 2071, "KIND": "PARABOLE PLATE"}
],
"totalCount": 4,
"success": true
},
{
"success": true,
"FANTENNE": [
{"ID": 1121, "CONNECT": "Autre"},
{"ID": 1122, "CONNECT": "Neovia"},
{"ID": 1124, "CONNECT": "non"},
{"ID": 1125, "CONNECT": "oui"},
{"ID": 1126, "CONNECT": "Patch"},
{"ID": 1127, "CONNECT": "SRTD"},
{"ID": 1128, "CONNECT": "Standard"}
],
"totalCount": 7
},
{
"MANTENNE": [
{"ID": 2065, "STATUS": "NON PRESENTE", "ACTION": 1},
{"ID": 2066, "STATUS": "DEFECTUEUSE", "ACTION": 2},
{"ID": 2067, "STATUS": "2EME ANTENNE POSEE", "ACTION": 3}
],
"totalCount": 3,
"success": true
},
{
"totalCount": 5,
"LANTENNE": [
{"ID": 1139, "LOCATION": "AU SOL"},
{"ID": 1140, "LOCATION": "Balcon"},
{"ID": 1142, "LOCATION": "FACADE"},
{"ID": 1143, "LOCATION": "Toit"},
{"ID": 2064, "LOCATION": "JARDIN"}
],
"success": true
},
],
"success": true
}
鉴于我有核心数据实体(以及所有单个叶对象(、、、、TANTENNE
)FANTENNE
的MANTENNE
关联类LANTENNE
。
当我收到上述 JSON 时,我想插入 4 个实例TANTENNE
、7 个实例FANTENNE
、3 个实例MANTENNE
和 5 个实例LANTENNE
。
我对这些类有单独的映射,例如:
RKManagedObjectMapping *mapping = [RKManagedObjectMapping mappingForEntityWithName:@"TANTENNE" inManagedObjectStore:self.objectStore];
mapping.primaryKeyAttribute = @"id";
[mapping mapKeyPathsToAttributes:
@"ID", @"id",
@"KIND", @"kind",
nil];
[self setObjectMapping:mapping forKeyPath:@"TANTENNE"];
这在我的映射提供程序的初始化时调用。但这显然还不够,因为我收到控制台消息,例如
[…] T restkit.object_mapping:RKObjectMapper.m:293 Examining keyPath 'TANTENNE' for mappable content...
[…] D restkit.object_mapping:RKObjectMapper.m:303 Found unmappable value at keyPath: TANTENNE
如果我使用“All_Combo.TANTENNE”键路径添加映射,则 RestKit 稍后会在尝试将完整数组映射到一个目标对象时崩溃。
这是 RestKit 0.10(我还没有迁移到 0.20,因为所有 Magical Record 的东西都不见了,而且我经常使用它)。
感谢您的任何见解。