Tengo algunos problemas al mapear una matriz JSON a RestKit. Así es como se ve el archivo JSON:Cómo mapear matrices JSON en RestKit
{"issuelist":[
{
"issue":[
{
"id":1,
"beschreibung":"",
"name":"Test1"
},
{
"id":2,
"beschreibung":"",
"name":"Test2"
}
]
}
]}
Estoy interesado en la serie "issue" s. Este es mi asignación para un solo tema:
RKObjectMapping *objectMapping = [RKObjectMapping mappingForClass:[self class] usingBlock:^(RKObjectMapping *mapping) {
[mapping mapAttributes:@"name", @"beschreibung", nil];
[mapping mapKeyPathsToAttributes:
@"id", @"identifier",
nil];
}];
Y aquí es cómo puedo configurar mi ObjectMapping
RKObjectMappingProvider *omp = [RKObjectManager sharedManager].mappingProvider;
RKObjectMapping *issueMapping = [Issue mapping];
[omp addObjectMapping:issueMapping];
[omp setObjectMapping:issueMapping forKeyPath:@"issuelist.issue"];
Desafortunadamente esto no funciona. Me aparece un resultado del registro de la siguiente manera:
T restkit.object_mapping:RKObjectMappingOperation.m:152 Found transformable value at keyPath 'name'. Transforming from type '__NSArrayI' to 'NSString' W restkit.object_mapping:RKObjectMappingOperation.m:232 Failed transformation of value at keyPath 'name'. No strategy for transforming from '__NSArrayI' to 'NSString' T restkit.object_mapping:RKObjectMappingOperation.m:339 Skipped mapping of attribute value from keyPath 'name to keyPath 'name' -- value is unchanged ((null)) T restkit.object_mapping:RKObjectMappingOperation.m:322 Mapping attribute value keyPath 'beschreibung' to 'beschreibung' T restkit.object_mapping:RKObjectMappingOperation.m:152 Found transformable value at keyPath 'beschreibung'. Transforming from type '__NSArrayI' to 'NSString' W restkit.object_mapping:RKObjectMappingOperation.m:232 Failed transformation of value at keyPath 'beschreibung'. No strategy for transforming from '__NSArrayI' to 'NSString' T restkit.object_mapping:RKObjectMappingOperation.m:339 Skipped mapping of attribute value from keyPath 'beschreibung to keyPath 'beschreibung' -- value is unchanged ((null)) T restkit.object_mapping:RKObjectMappingOperation.m:322 Mapping attribute value keyPath 'id' to 'identifier' T restkit.object_mapping:RKObjectMappingOperation.m:152 Found transformable value at keyPath 'id'. Transforming from type '__NSArrayI' to 'NSString' W restkit.object_mapping:RKObjectMappingOperation.m:232 Failed transformation of value at keyPath 'id'. No strategy for transforming from '__NSArrayI' to 'NSString' T restkit.object_mapping:RKObjectMappingOperation.m:339 Skipped mapping of attribute value from keyPath 'id to keyPath 'identifier' -- value is unchanged ((null)) D restkit.object_mapping:RKObjectMappingOperation.m:624 Finished mapping operation successfully...
Parece como si RestKit está tratando de mapear toda la arry en una emisión en lugar de crear una serie de cuestiones. ¿Cómo debo cambiar mi asignación para corregir esto?
Gracias por su ayuda!
Gracias! Eso fue útil! – thalador