使用jsonkit iOS解析json提要 [英] parse json feeds using jsonkit iOS

查看:149
本文介绍了使用jsonkit iOS解析json提要的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用此处的JSONKIt https://github.com/johnezang/JSONKit解析JSON Feed并放入objective-c对象。我是iOS的新手,并不知道从哪里开始。有没有使用这个库的好教程?

解决方案

谷歌搜索后,我没有找到任何教程,但使用JSONKit应该是自我解释。



使用NSURLConnection或ASIHTTPRequest下载JSON源后,只需创建一个JSON源中所有对象的字典,如下所示:

  // jsonString是你下载的字符串JSON Feed 
NSDictionary * deserializedData = [jsonString objectFromJSONString];

//有用的片段,用于记录所有反序列化的对象及其键
NSLog(@%@,[deserializedData description]);

创建字典后,您可以执行以下操作:

  NSString * string = [deserializedData objectForKey:@someJSONKey]; 

这是JSONKit背后的基础。



<当然,JSONKit功能更强大,您可以在JSONKit.h中找到其他一些可以用它做的事情。


I'm trying to use the JSONKIt found here https://github.com/johnezang/JSONKit to parse through a JSON Feed and put into objective-c objects. I'm new at iOS and don't really know where to start. Are there any good tutorials for using this library?

解决方案

After googling, I didn't find any tutorials but using JSONKit should be self explanatory.

After downloading your JSON feed using NSURLConnection or ASIHTTPRequest simply create a dictionary of all the objects in the JSON feed like so:

//jsonString is your downloaded string JSON Feed
NSDictionary *deserializedData = [jsonString objectFromJSONString];

//Helpful snippet to log all the deserialized objects and their keys
NSLog(@"%@", [deserializedData description]);

After creating a dictionary you can simply do something like this:

    NSString *string = [deserializedData objectForKey:@"someJSONKey"];

And that is the basics behind JSONKit.

JSONKit is much more powerful of course, you can find some of the other things you can do with it in JSONKit.h

这篇关于使用jsonkit iOS解析json提要的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆