JSONKit的使用

前端之家收集整理的这篇文章主要介绍了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

原文链接:https://www.f2er.com/json/290582.html

猜你在找的Json相关文章