Created
January 31, 2014 06:51
-
-
Save osmszk/8727614 to your computer and use it in GitHub Desktop.
Convert to JSON from NSDictionary
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (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