github/Mantle — pull request #102 by cloudkite (2013-07-05 12:13:11+00:00)
Title: Ability to have alternative JSON keypaths for a model property

Unfortunately we don't all work with nice shiny APIs like github's :P.
In my experience APIs are often very inconsistent with their naming of json fields. take for example a Person json object in one API call the returned object might be:

{
"person_id" : "234",
"first_name" : "bob"
}

however in another api call the person object might be returned as

{
"personId" : "234",
"first_name" : "bob"
}

proposed solution is to allow mutliple keypaths for a single MTLModel property ie:

+ (NSDictionary *)JSONKeyPathsByPropertyKey {
return @{
@"personId": @[ @"personId", @"person_id" ],
@"firstName": @"first_name",
};
}

MTLJSONAdapter will use the first value it finds and also save which keypath we mapped a property to so we can reverse it with the same keypath