如何在iPhone中将JSON数据转换为对象 [英] How to convert JSON data to Objects in iPhone
问题描述
可能重复:
如何使用目标C获取和解析JSON?
Possible Duplicate:
How to get and parse JSON using objective C?
最近我发现JSON可用于将数据发送到iPhone.
Recently I have discovered JSON can be used to send data to iPhone.
在我的应用程序中,服务器之间存在很多通信,因此我在各个地方构造了许多对象(类).目前,我正在根据从json获得的数据手动构建类.
In my application there is lot of communication between the server so I construct lot of objects (classes) in various places. Currently I am manually constructing my classes from the data I get from json.
在我们知道从服务中获取的对象信息之后,是否有框架或源代码可以自动进行此转换.我可以传递类结构,它将根据json数据创建这些对象的数组.
Is there a framework or source code that does this conversion automatically after all we know object information we get from the service. I can pass the class structure and it will create a Array of those objects from json data.
推荐答案
是:
http://code.google.com/p/json-framework/
导入框架,发送JSON字符串-[NSString JSONValue]
,您将获得NSDictionary
或NSArray
.
Import the framework, send the JSON string -[NSString JSONValue]
and you'll get back either an NSDictionary
or an NSArray
.
这篇关于如何在iPhone中将JSON数据转换为对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!