iOS 的 JSON 解析库:YAJL-Entity
jopen
11年前
YAJL-Entity 是 iOS 上对 JSON 字符串进行反序列化到对象以及对象到 JSON 序列化的库。
NSString *path = [[NSBundle mainBundle] pathForResource:@"my-entity.json" ofType:nil]; NSData *data = [NSData dataWithContentsOfFile:path]; // Deserialization MyEntity *entity = [data objectFromJSONOfType:[MyEntity class]]; // Serialization. // You have to implement - (id)JSON method in your entity class. This is easy to do. See the next section. NSString *jsonString = [entity yajl_JSONString];