ios - Object from JSON with Mantle: ignore a property -
my app creates objc objects json. things working fine, until added new property objc model class, doesn't have counterpart in json.
i've configured mapping follows:
+ (nsdictionary *)jsonkeypathsbypropertykey { return @{ @"firstname" : @"firstname", @"middlename" : @"middlename", @"lastname" : @"lastname", // etc. @"phonenumber" : nsnull.null // no json data 1 }; }
however assertion failure in mantle, in mtljsonadapter initwithmodelclass
: "phonenumber must either map json key path or json array of key paths, got: null."
this how create model object:
mydata *mydata = [mtljsonadapter modelofclass:[mydata class] fromjsondictionary:json error:&error];
how can have phonenumber
property in data class without mapping json value?
just don't specify mapping + jsonkeypathsbypropertykey
.
Comments
Post a Comment