CocoaPods trunk is moving to be read-only. Read more on the blog, there are 12 months to go.
| TestsTested | ✓ |
| LangLanguage | Obj-CObjective C |
| License | MIT |
| ReleasedLast Release | Aug 2016 |
Maintained by Mert Buran.
I looked at other libraries but none of them seemed simple/minimal enough to me. The whole idea of this library is being as small as possible:
{
"middleName" = "Hatice"
"name" = "John"
"surname" = "Appleseed"
}#import <MBJSONMapper/MBJSONSerializable.h>
@interface TestDataModel : NSObject <MBJSONSerializable>
@property (nonatomic, copy, readonly) NSString *name;
@property (nonatomic, copy, readonly) NSString *middleName;
@property (nonatomic, copy, readonly) NSString *surname;
@end@implementation TestDataModel
// Nothing!
@end{
"isItTrue" = 1
"middleName" = "Hatice"
"name" = "John"
"surname" = "Appleseed"
"nestedModel" = {
"middleName" = ""
"name" = "Nested"
"surname" = "John"
}
"nestedModels" = (
{
"middleName" = "1"
"name" = "John"
"surname" = "Dupont"
},
{
"middleName" = "2"
"name" = "John"
"surname" = "Dupont"
},
{
"middleName" = "3"
"name" = "John"
"surname" = "Dupont"
}
)
}#import <MBJSONMapper/MBJSONSerializable.h>
@interface TestDataModel : NSObject <MBJSONSerializable>
@property (nonatomic, readonly) BOOL isItTrue;
@property (nonatomic, copy, readonly) NSString *name;
@property (nonatomic, copy, readonly) NSString *surname;
@property (nonatomic, copy, readonly) NSString *secondName;
@property (nonatomic, copy, readonly) NSString *nestedModelName;
@property (nonatomic, copy, readonly) TestDataModel *nestedModel;
@property (nonatomic, copy, readonly) NSArray<TestDataModel*> *nestedModels;
@end@implementation TestDataModel
- (NSDictionary<NSString*, NSString*> *)keyPropertyMappingDictionary {
return @{@"nestedModel.name": NSStringFromSelector(@selector(nestedModelName)),
@"middleName": NSStringFromSelector(@selector(secondName))};
}
- (NSDictionary<NSString*, Class> *)keyClassMappingDictionary {
return @{NSStringFromSelector(@selector(nestedModel)): [TestDataModel class],
NSStringFromSelector(@selector(nestedModels)): [TestDataModel class]};
}
@endThat's all folks!
To run the example project, clone the repo, and run pod install from the Example directory first.
MBJSONMapper is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "MBJSONMapper"Mert Buran, [email protected]
MBJSONMapper is available under the MIT license. See the LICENSE file for more info.