User对象:
@interface User : NSObject
@property (nonatomic, strong) NSString *name;
@property (nonatomic, strong) NSNumber *age;
@end
User *user = [[User alloc]init];
NSString *jsonStringSource = @"{\"name\":\"张三\",\"age\":\"10\"}";
NSData *jsonDataSource = [jsonStringSource dataUsingEncoding:NSUTF8StringEncoding];
NSDictionary *jsonObj = [NSJSONSerialization JSONObjectWithData:jsonDataSource options:NSJSONReadingAllowFragments error:nil];
[user setValuesForKeysWithDictionary:jsonObj];
数据结果: