Model 属性名与网络数据不一致, 使用JSONKeyMapper
1. 重新映射不一致的属性
Model 属性名:desc, 网络数据字段名:description
+(JSONKeyMapper*)keyMapper
{
return [[JSONKeyMapper alloc] initWithModelToJSONBlock:^NSString*(NSString *keyName) {
if([keyName isEqualToString:@"desc"]) {
return @"description";
}
return keyName;
}];
}
2. 重新映射所有属性
[[JSONKeyMapper alloc] initWithModelToJSONDictionary:@{
@"_id": @"_id",
@"author": @"author",
@"avatar": @"avatar",
@"createdAt": @"createdAt",
@"desc": @"description"
}];