gpt4 book ai didi

iphone - Reskit v0.2 json 格式映射

转载 作者:行者123 更新时间:2023-11-29 03:44:40 25 4
gpt4 key购买 nike

{
"JobID" : "aaaabbbb-dddd-eeee-ffff-aaaabbbbcccc",
"UserID": "11112222-dddd-eeee-ffff-111122223333",

"FolderVersions" : [
{
"FolderID" : "11112222-dddd-eeee-ffff-111122223333",
"Version" : "1.0"
},
{
"FolderID" : "11113333-dddd-eeee-ffff-111122223333",
"Version" : "1.2"
},
{
"FolderID" : "33332222-dddd-eeee-ffff-111122223333",
"Version" : "1.1"
}
]
}

我有包含 jobid、userid 和 nsmutable_array“folderversion”的作业类

FolderVersions:使用具有folder_id和版本的FolderVersion类进行映射

我希望将FolderVersions映射到作业类中的folderversion数组

RKObjectMapping *jobMapping = [RKObjectMapping mappingForClass:[Job class]];
[jobMapping addAttributeMappingsFromDictionary:@{
@"JobID" : @"jobId",@"USerID":@"userID"
}];



RKObjectMapping *folderMapping = [RKObjectMapping mappingForClass:[FolderVersion class]];
[folderMapping addAttributeMappingsFromDictionary:@{@"FolderID":@"folderID",

@"Version":@"version",

}];



RKResponseDescriptor *responseDescripor1 = [RKResponseDescriptor jobMapping
method:RKRequestMethodPOST pathPattern:@"/xxx/response.php/json/response"

keyPath:nil statusCodes:RKStatusCodeIndexSetForClass(RKStatusCodeClassSuccessful)];

最佳答案

您需要向 jobMapping 添加关系映射,它将 Job 类中的键链接到 JSON 中的键 (FolderVersions code>) 并指定它应该使用 folderMapping 来存储内容:

[jobMapping addPropertyMapping:[RKRelationshipMapping relationshipMappingFromKeyPath:@"FolderVersions" toKeyPath:@"folderversion" withMapping:folderMapping]];

关于iphone - Reskit v0.2 json 格式映射,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17897629/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com