Skip to content

Instantly share code, notes, and snippets.

@osmszk
Created January 31, 2014 06:51
Show Gist options
  • Save osmszk/8727614 to your computer and use it in GitHub Desktop.
Save osmszk/8727614 to your computer and use it in GitHub Desktop.
Convert to JSON from NSDictionary
- (void)convertToJsonFromDictionary
{
NSDictionary *paramDic = @{@"flg": @"true",
@"result":[NSNull null]};
NSData *paramData = nil;
if([NSJSONSerialization isValidJSONObject:paramDic]){
paramData = [NSJSONSerialization dataWithJSONObject:paramDic options:NSJSONWritingPrettyPrinted error:nil];
NSLog(@"%@",paramDic);
NSLog(@"%@",[[NSString alloc] initWithData:paramData encoding:NSUTF8StringEncoding]);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment