-4
{"data":[
         "",{"id":"1","nom":"hello","message":["",{"id":1,"nom":"dad"}]},
            {"id":"2","nom":"hi","message":["",{"id":"1","nom":"marie"},{"id":"2","nom":"bob"}]}
        ]
} 

我如何使用 iOS 从中提取数据

4

2 回答 2

0

利用NSJSONSerialization.

NSError *jsonError = nil;
id allValues = [NSJSONSerialization JSONObjectWithData:[str dataUsingEncoding:NSUTF8StringEncoding]
                                                                      options:0
                                                                        error:&jsonError];

if(jsonError!=nil)
   NSLog(@"Json_Err: %@",jsonError);

NSArray *result = [(NSDictionary*)allValues objectForKey:@"data"];
于 2013-03-08T12:04:59.723 回答
0

为您的项目集成 Json sdk 并像这样放置以下代码...

NSStrig *jsonString = @"your json string";
NSDictionary *responseDictionary = [jsonString JSONValue];
于 2013-03-08T12:11:48.203 回答