请帮助从以下JSON
进行映射{
meta: {}
notifications: []
response: {
suggestedFilters: {}
suggestedRadius: 922
headerLocation: "Manhattan"
headerFullLocation: "Manhattan"
headerLocationGranularity: "city"
totalResults:
suggestedBounds: {}
groups: [
{
type: "Recommended Places"
name: "recommended"
items: [
{
reasons: {}
venue: {
id: "430d0a00f964a5203e271fe3"
name: "Brooklyn Bridge Park"
contact: {}
location: {}
categories: []
verified:
stats: {}
likes: {}
like:
rating:
hours: {}
specials: {}
photos: {}
hereNow: {}
}
tips: []
referralId: "e-0-430d0a00f964a5203e271fe3-0"
}
{
到具有属性的Venue对象
@property (nonatomic, copy) NSString *ID;
@property (nonatomic, copy) NSString *name;
我需要映射响应>群组>场地> id TO" id" 和响应>群组>场地>名称TO"名称"
我写这个
NSIndexSet *statusCodeSet = RKStatusCodeIndexSetForClass(RKStatusCodeClassSuccessful);
RKResponseDescriptor *responseDescriptor = [RKResponseDescriptor responseDescriptorWithMapping:[MappingProvider venueMapping]
method:RKRequestMethodGET
pathPattern:@"/v2/venues/explore"
keyPath:@"response"
statusCodes:statusCodeSet];
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@/venues/explore?ll=40.7,-74&oauth_token=%@",
[[DataManager sharedManager] baseURL], [[DataManager sharedManager] anonymusUserAccessToken]]];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
RKObjectRequestOperation *operation = [[RKObjectRequestOperation alloc] initWithRequest:request
responseDescriptors:@[responseDescriptor]];
[operation setCompletionBlockWithSuc.....
但它不起作用
谢谢
答案 0 :(得分:1)
您无法直接映射到该级别,因为映射无法处理索引到2个不同的数组(组和项)。您需要创建处理这些数组的映射,在这种情况下,通过创建并映射到容器对象(组),以便您可以处理items数组(及其包含的场所)。