Skip to content

Instantly share code, notes, and snippets.

@FlaviuSim
Created April 25, 2012 18:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FlaviuSim/2492231 to your computer and use it in GitHub Desktop.
Save FlaviuSim/2492231 to your computer and use it in GitHub Desktop.
// create a JSON string from your NSDictionary
NSError *error;
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:finalDict
options:NSJSONWritingPrettyPrinted // Pass 0 if you don't care about the readability of the generated string
error:&error];
NSString *jsonString = [[NSString alloc] init];
if (!jsonData) {
NSLog(@"Got an error: %@", error);
} else {
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