我遇到了向服务器发布字符串数组的问题:
我的映射是:
+(RKMapping*)occurrenceCreateMapping {
RKObjectMapping *occurrenceCreateMapping = [RKObjectMapping requestMapping];
[occurrenceCreateMapping addAttributeMappingsFromDictionary:@{
@"observedOn" :@"ObservedOn",
@"latitude" :@"Latitude",
@"longitude" :@"Longitude",
@"address" :@"Address",
@"host" :@"Host",
@"pests" : @"Pests",
@"networkId" :@"NetworkId",
@"consignmentNumber" :@"ConsignmentNumber"
}];
return occurrenceCreateMapping;
}
但实际上发布的是:
这是无效的,因为我的服务器端模型绑定器需要一个字符串数组。
这是我的OccurrenceCreate类的代码:
@interface BBOccurrenceCreate : NSObject
@property (nonatomic, retain) NSDate *observedOn;
@property CGPoint location;
@property (nonatomic, retain) NSString *latitude,
*longitude,
*address,
*host,
*consignmentNumber,
*networkId;
@property (nonatomic,retain) NSArray *pests;
@end
任何人都可以帮我将这个字符串数组映射到json数组吗?我觉得这应该很简单?!?!
答案 0 :(得分:1)
您可能缺少序列化类型设置,因此RestKit默认为form-url-encoded。显式设置序列化类型以指示RestKit生成JSON。