JSONKit的使用方法

2021-06-22 10:37:50 字數 854 閱讀 7224

json開源的類庫有很多,其中jsonkit庫是非常簡單易用而且效率又比較高的,重要的jsonkit適用於ios 5.0以下的版本使用.

//假設 strjson 是網路上接收到的 json 字串,

nsstring *strjson = @"[,]"; 

nsarray *arrlist=[strjson objectfromjsonstring];

nslog(@"%d",[arrlist count]);

for (int i=0; i<[arrlist count]; i++)

字典arrlist便是解析好的json檔案了。

jsonkit庫也可以用來生成json檔案

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.***" forkey:@"sound"];

[jsondic setobject:aps forkey:@"aps"];

nsstring *strjson = [jsondic jsonstring];

JSONKit的使用方法

json開源的類庫有很多,其中jsonkit庫是非常簡單易用而且效率又比較高的,重要的jsonkit適用於ios 5.0以下的版本。解析 舉例 import jsonkit.h 假設 strjson 是網路上接收到的 json 字串,nsstring strjson nsarray arrlist ...

JsonKit簡單使用

cocoa 下json開源的類庫有很多,其中jsonkit庫是非常簡單易用而且效率又比較高的。解析 舉例 import jsonkit.h 假設 strjson 是網路上接收到的 json 字串,nsstring strjson bage 3,sound def.nsdictionary resul...

JSONKit的使用(PS 勿使用SBJson)

jsonkit庫是非常簡單易用而且效率又比較高。解析 舉例 import jsonkit.h 假設 strjson 是網路上接收到的 json 字串,nsstring strjson nsarray arrlist strjson objectfromjsonstring nslog d arrli...