Skip to content

Instantly share code, notes, and snippets.

@mteece
Created July 16, 2013 13:52
Show Gist options
  • Save mteece/6008889 to your computer and use it in GitHub Desktop.
Save mteece/6008889 to your computer and use it in GitHub Desktop.
Generate JSON from an NSDictionary.
NSError *error;
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:dictionaryOrArrayToOutput options:NSJSONWritingPrettyPrinted error:&error];
if (!jsonData) {
NSLog(@"Got an error: %@", error);
} else {
NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment