TestsTested | ✗ |
LangLanguage | Obj-CObjective C |
License | MIT |
ReleasedLast Release | Apr 2017 |
Maintained by Huy Pham.
I know many of open source out there have feature JSON deserialization, but you need to keep implement boring mapping functions by your hand. I created Mapper with objetive-c runtime so you don't need to do it anymore. It's awesome.
Mapper can integrate with Swift probject (as example), map JSON to objects and map objects to JSON without manual implementation. It's very simple and easy to use.
pod "HPMapper"
// Create model inheritance Mapper class and that's all
// Objective-C (Recommended)
#import "Mapper.h"
@interface BaseModel : Mapper
@property (nonatomic, copy) NSString *ID;
@property (nonatomic, copy) NSString *Name;
@end
// Or Swift
class Carrot: Mapper {
dynamic var ID: NSString!
dynamic var Name: NSString!
}
let model = Model()
// Init it with json
model.initData(["Name": "Carrot", "ID": "A2jsdk"])
// Or simple
let model = Model(dictionary: ["Name": "This name", "ID": "This is ID from super class"])
model.toDictionary()
// Setup selector trigger
model.property("Name", target: self, selector: #selector(ChangeName), on: .onChange)
// Change value then ChangeName will be called
model.name = "New name"