Latest 0.0.3
Homepage https://github.com/songyutao/YTGenerator
License MIT
Platforms ios , requires ARC
Dependencies Reachability
Frameworks Foundation
Authors

YTGenerator automatically generates objects based on JSON data .

YTGenerator is not a Json parser, before using YTGenerator, you need to convert the Json data into NSDictionary.

It supports nested types, arrays, NSString, and others.

Examples:

Json:

    {
        "name": "song",
        "age": 20,
        "money": @"234.34",
        "friends": [
            {
                "name": "lisi",
                "age": 30
            }
        ]
    }

follow class:

YTPROTOCOL_FOR_CLASS(User) Nested Objects

YTPROTOCOL_FOR_CLASS(User)
@interface User : NSObject

@property(nonatomic, copy  )NSString        *name;
@property(nonatomic, assign)NSUInteger      age;
@property(nonatomic, assign)double          money;
@property(nonatomic, strong)NSArray<User>   *friends;

@end

use way:

User *user = (User *)[YTGenerator newObjectWithClassName:[User class] jsonDict:jsonUser];
NSLog(@"name=%@", user.name);
NSLog(@"age=%@",  @(user.age));
NSLog(@"friends=%@", user.friends);
NSLog(@"money=%lf", user.money);

NSDictionary *jsonUserUpdate = @{@"name":@"lisi",
                                 @"age":@39};

[YTGenerator updateObject:user jsonDict:jsonUserUpdate];
NSLog(@"name=%@", user.name);
NSLog(@"age=%@",  @(user.age));
NSLog(@"friends=%@", user.friends);

Latest podspec

{
    "name": "YTGenerator",
    "platforms": {
        "ios": null
    },
    "version": "0.0.3",
    "license": "MIT",
    "summary": "Auto translates NSDictionary to instansces of Objective-C classes, supporting nested types and arrays.",
    "homepage": "https://github.com/songyutao/YTGenerator",
    "authors": {
        "u5b8bu7389u6d9b": "[email protected]"
    },
    "source": {
        "git": "https://github.com/songyutao/YTGenerator.git",
        "tag": "0.0.3"
    },
    "source_files": "YTGenerator/YTGenerator",
    "frameworks": [
        "Foundation"
    ],
    "dependencies": {
        "Reachability": []
    },
    "requires_arc": true
}

Pin It on Pinterest

Share This