【发布时间】:2016-02-20 04:26:38
【问题描述】:
我需要解析一个 JSON Web 服务响应,其中包含一个子项未知的键。
例如,让我们有以下 JSON 响应,其中 customData 属性的键是在运行时定义的:
{
"score": 996,
"customData": { "key1": "key1value", "key2": "key2value" },
"isRegistered": true,
"allowOpening": "OK"
}
是否可以将 customData 的 JSON 内容保存到字符串 coredata 属性中?
我尝试过这样一个简单的映射:
RKEntityMapping *mapping = [RKEntityMapping mappingForEntityForName:[[self class] description] inManagedObjectStore:managedObjectStore];
[mapping addAttributeMappingsFromDictionary:@{
@"score": @"score",
@"customData":@"customData",
@"isRegistered": @"isRegistered",
@"allowOpening": @"allowOpening"}];
但是不行,coredata保存的customData一直是空的。
非常感谢, 丹
【问题讨论】:
标签: ios core-data mapping restkit