JSONKit的使用

1.将字典或者数组反序列化为NSString.
   


    NSMutableDictionary *jsonDic = [NSMutableDictionary dictionary];
    NSMutableDictionary *alert = [NSMutableDictionary dictionary];
    NSMutableDictionary *aps = [NSMutableDictionary dictionary];
    [alert setObject:@"a msg come!" forKey:@"body"];
    [aps setObject:alert forKey:@"alert"];
    [aps setObject:@"3" forKey:@"bage" ];
    [aps setObject:@"def.mp3" forKey:@"sound"];
    [jsonDic setObject:aps forKey:@"aps"];
   
    NSString *strJson = [jsonDic JSONString];
   
    NSLog(@"%@",strJson);


2.将NSString反序列化为数组、字典.
    NSDictionary *result = [strJson  objectFromJSONString];
或者
   NSDictionary *result = [dataJson  objectFromJSONData];
   
    NSLog(@"333%@",result);

 

 

社区原帖:http://www.cocoachina.com/bbs/read.php?tid=125929


你可能感兴趣的:(JSONKit的使用)