Yup NSJSONSerializationis the way:
NSString *fileName = @"myJsonDict.dat";
NSDictionary *dict = @{ @"key" : @"value" };
NSOutputStream *os = [[NSOutputStream alloc] initToFileAtPath:fileName append:NO];
[os open];
[NSJSONSerialization writeJSONObject:dict toStream:os options:0 error:nil];
[os close];
NSInputStream *is = [[NSInputStream alloc] initWithFileAtPath:fileName];
[is open];
NSDictionary *readDict = [NSJSONSerialization JSONObjectWithStream:is options:0 error:nil];
[is close];
NSLog(@"%@", readDict);
source
share