当前位置: 动力学知识库 > 问答 > 编程问答 >

ios - Mapping the response data in RestKit

问题描述:

I had used restkit in my project and i am trying to map the json data.

Response data format is from json GET webservice is :

 [

{

"Id":"XXXX",

"detailId":"XXXX",

"OriginalTitle":"XXXX"

},

{

"Id":"XXXX,

"detailId":"XXXX",

"OriginalTitle":"XXXX"

}

]

How can i map the data with any key.

Generally i use below to map

 RKObjectMapping *objectMapping = [RKObjectMapping mappingForClass:[self class]];

[objectMapping addAttributeMappingsFromDictionary:@{@"status":@"strStatus",

@"message":@"strMessage"}];

[objectMapping addPropertyMapping:[RKRelationshipMapping relationshipMappingFromKeyPath:@"***MyKeyfromAPI***" toKeyPath:@"MyArrayVariableInProject" withMapping:[***SomeModelClass*** mapping]]];

Error are something like :

[request=1.0424s mapping=0.0000s total=1.2667s]: Error Domain=org.restkit.RestKit.ErrorDomain Code=1001 "No response descriptors match the response loaded."

{Error Domain=org.restkit.RestKit.ErrorDomain Code=1001 "No mappable object representations were found at the key paths searched." UserInfo={NSLocalizedDescription=No mappable object representations were found at the key paths searched., NSLocalizedFailureReason=The mapping operation was unable to find any nested object representations at the key paths searched:

This likely indicates that you have misconfigured the key paths for your mappings., keyPath=null, DetailedErrors=(

)}}, keyPath=null, NSLocalizedDescription=No response descriptors match the response loaded.}

but in the response i have any key for array.

How can i map this. Please help.

分享给朋友:
您可能感兴趣的文章:
随机阅读: