RestKit Mapeamento com uma matriz de objetos complexos

Eu estava analisando muito bem meu JSON, mas meu servidor acabou de mudar. Meu JSON costumava ficar assim:

{
    "blobs": [  
        {
            "createdOn": "2012-03-16T15:13:12.551Z",
            "description": "Fake description",
            "hint": "And a useless hint",
            "id": 400,
            "name": "Fake CA one",
            "publicId": "FF6",
            "type": 0
        },
        {
            "createdOn": "2012-03-16T17:33:48.514Z",
            "description": "No hint on this one, but it does have a description.",
            "hint": "Hint",
            "id": 402,
            "name": "Second fake one in CA",
            "publicId": "FF8",
            "type": 0
        }
    ]
}

e meu mapeamento ficou assim:

RKObjectMapping* blobMapping = [RKObjectMapping mappingForClass:[GetResponseInRegionResponse class]];

[blobMapping mapKeyPath:@"name" toAttribute:@"name"];
[blobMapping mapKeyPath:@"id" toAttribute:@"blobId"];
[blobMapping mapKeyPath:@"description" toAttribute:@"description"];
[blobMapping mapKeyPath:@"hint" toAttribute:@"hint"];

[[RKObjectManager sharedManager].mappingProvider setMapping:blobMapping forKeyPath:@"blobs"];

gora, meu servidor mudou e eu recebo de volta:

{
    "blobsList": {
        "blobs": [  
            {
                "createdOn" :"2012-03-16T15:13:12.551Z",
                "description": "Fake description",
                "hint": "And a useless hint",
                "id": 400,
                "name": "Fake CA one",
                "publicId": "FF6",
                "type": 0
            },
            {
                "createdOn": "2012-03-16T17:33:48.514Z",
                "description": "No hint on this one, but it does have a description.",
                "hint": "Hint",
                "id": 402,
                "name": "Second fake one in CA",
                "publicId": "FF8",
                "type": 0
            }
        ]
    }
}

Então adicionei isso ao meu mapeamento:

RKObjectMapping* blobsListMapping = [RKObjectMapping mappingForClass:[GetResponseInRegionResponseList class]];
[blobsListMapping mapKeyPath:@"blobsList" toAttribute:@"blobsList"];

[[RKObjectManager sharedManager].mappingProvider setMapping:blobsListMapping forKeyPath:@"blobsList"];

E são minhas classes:

@interface GetResponseInRegionResponse : NSObject
{
    NSString* name;
    NSString* blobId;
    NSString* description;
    NSString* hint;
}       

@interface GetResponseInRegionResponseList : NSObject
{
    NSArray  *blobsList;
}

Quando analiso esse JSON, recebo um objeto que possui um JKArray de 2 objetos, ambos são objetos JKDictionary. Claramente, esses são meus dados, mas estão no formato JKDictionary. Ele nunca foi mapeado para a classe GetResponseInRegionResponse!

De ler os documentos do github, parece que eu quero usar um método toRelationship para matrizes, mas não estou vendo onde colocá-lo. Se eu seguir o exemplo "articles" e tentar o seguinte:

[blobListMapping mapKeyPath:@"blobs" toAttribute:@"blobsList"];
[blobListMapping mapKeyPath:@"blobs" toRelationship:@"blobsList" withMapping:blobMapping];

Eu recebo esta exceção:

2012-03-19 14:59:53.704 Ferret[8933:16303] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Unable to add mapping for keyPath blobsList, one already exists...'

Como posso mapear um array de objetos complexos dentro do meu JSON?

Agradeço qualquer ajuda. Obrigado

questionAnswers(4)

yourAnswerToTheQuestion