如何解析数组?

时间:2012-07-11 05:25:03

标签: iphone ios ipad

我有一个应用程序,我从web服务得到这样的响应。任何人都可以告诉我如何解析它以使其成为单独的字符串"Info":

{
  "name":"gdgdgdgd",
  "desc":"Cosmopolitan life, adventurous outlook, 'been there done that' attitude, and yet the way the life ...",
  "address1":" 2nd A Main ",
  "address2":" Layout,"
},

2 个答案:

答案 0 :(得分:2)

这是对象的JSON表示。

在iOS 5中,我们将JSON类添加为NSJSONSerialization

这是一个教程:

http://www.raywenderlich.com/5492/working-with-json-in-ios-5

这是另一个讨论其他选项的线程,比如JSONKit,YAJL

Native JSON support in iOS?

答案 1 :(得分:-1)

使用json库

这样做

NSMutableDictionary * listd = [dict objectForKey:@“merchantInfo”];

if([listd isKindOfClass:[NSDictionary class]])

{

   stringshopname=[listd objectForKey:@"name"]; 
   stringshopdesc=[listd objectForKey:@"desc"];


}