Mantle / Mantle

Model framework for Cocoa and Cocoa Touch

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Map multiple json field when key name is same

siam009 opened this issue · comments

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.

Try @[@"x": @"a.value"], as they are keypaths.

Feel free to reopen this if the problem persists.