Thursday 21 November 2013

How to convert NSMutableDictionary to JSONString...

NSMutableDictionary *dict = [[NSMutableDictionary alloc]init];
///Add records or any value and convert it like bellow...

NSData *jsonData = [NSJSONSerialization dataWithJSONObject:dict
                                                               options:0
                                                                 error:nil];
            
if (!jsonData) {
      NSLog(@"Error");
} else {
                
      NSString *JSONString = [[NSString alloc] initWithBytes:[jsonData  bytes] length:[jsonData length] encoding:NSUTF8StringEncoding];
      NSLog(@"\n\n JSON String ==>> %@",JSONString);
 }

No comments:

Post a Comment