Reputation: 39
I am currently using RestKit in our project but I am facing some issues to manage this structure:
{"Elements": [
{
"Element": {
"id": "1",
"property": "house",
"_addons": [
{
"Links": [
{
"Link": {
"id": "2",
"url": "http://www.google.com"
}
},
{
"Link": {
"id": "3",
"url": "http://www.google.com"
}
}
]
}
]
}
},
{
"Element": {
"id": "2",
"property": "garage",
"_addons": [
{
"Links": [
{
"Link": {
"id": "4",
"url": "http://www.google.com"
}
},
{
"Link": {
"id": "5",
"url": "http://www.google.com"
}
}
]
}
]
}
}
]
}
Right now in the object Element, there is the property "links" which is a NSMutableArray
(I tried also with `NSMutableDictionary but the problem is still there). Now,
if I try to do
[mapping addPropertyMapping:[RKRelationshipMapping relationshipMappingFromKeyPath:@"_addons.Links.Link" toKeyPath:@"links" withMapping:[Link mapping]]];
I receive an error saying that I wasn't possibile to map and there is a collection inside a collection.
The only solution I found was to include @"_addons.Links" : @"links"
in the mapping dictionary. In this case, though, I "lose" the chance to have the mapping to Link objects and I have to do it manually. Anybody has any advice?
Upvotes: 1
Views: 63
Reputation: 119031
You don't say exactly what you want, but the JSON does have an array in an array so you need to deal with that somehow. Options:
Generally, the first or last option is best. You are, it seems, already half way to the last option, you just need an extra mapping and relationship.
Upvotes: 1