2018-03-22

2018-04-17  本文已影响0人  我一不小心就
NSMutableArray *arr = [[NSMutableArray alloc] init];  

NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys:  
                        @"ni hao", @"key",  
                        @"45", @"value",  
                        @"USD", @"code",nil];  
  
NSDictionary *params2 = [NSDictionary dictionaryWithObjectsAndKeys:  
                        @"hao", @"key",  
                        @"45", @"value",  
                        @"USD", @"code",nil];  
[arr addObject:params];  
[arr addObject:params2];  
  
NSDictionary *params3 = [NSDictionary dictionaryWithObjectsAndKeys:  
                          arr, @"json",  
                         nil nil];  

//convert object to data  
NSData* jsonData =[NSJSONSerialization dataWithJSONObject:params3  
                                                  options:NSJSONWritingPrettyPrinted error:&error];    
  
//print out the data contents    
NSString* text =[[NSString alloc] initWithData:jsonData  
                                        encoding:NSUTF8StringEncoding];    
NSLog(@"json字典里面的内容为--》%@", text );
上一篇下一篇

猜你喜欢

热点阅读