Map multiple json field when key name is same
siam009 opened this issue · comments
siam009 commented
Initially I have a json like this:
{
"a": "dummy_value"
}
I am using this code
@implementation MyClass
+ (NSDictionary *)JSONKeyPathsByPropertyKey
{
return @{
@"x": @"a";
};
}
Now I also want to save a.value in same class MyClass and in same variable x. But i am stuck in it. How can i do this?
{
"a": {
"value": "dummy_value",
},
}
Note that i know when will i call which kind of json. But for my project purpose i have to keep this both call in same class and its just a part of my original class. key a can be an object or string. When it is string i will assign this value in x and if it is object i will assign a.value in x.
Robb Böhnke commented
Try @[@"x": @"a.value"]
, as they are keypaths.
Robb Böhnke commented
Feel free to reopen this if the problem persists.