Deserializing with TouchJSON
#import "CJSONDeserializer.h"
NSData *jsonData = [NSData dataWithContentsOfFile: path]; // or from network, or whatever
NSError *error;
NSArray *playlists =
[[CJSONDeserializer deserializer] deserializeAsArray: jsonData error: &error];
Serializing with TouchJSON
#import "CJSONSerializer.h"
NSArray *allSongs = [self allSongs];
NSString *jsonString = [[CJSONSerializer serializer] serializeObject: allSongs];
NSData *data = [jsonString dataUsingEncoding: NSUTF8StringEncoding];
// write |data| to a file, send over the network, etc
No comments:
Post a Comment