我JSON array
从我的服务器收到具有以下格式的:
{ messageArray:
[ { msgFrom: 'V351315826',
msgDate: Tue Oct 29 2013 04:00:35 GMT+0000 (UTC),
msgBody: 'Hi?',
channelID: 'V351315826' },
{ msgFrom: 'V351315826',
msgDate: Tue Oct 29 2013 04:00:38 GMT+0000 (UTC),
msgBody: 'Hello!',
channelID: 'V351315826' } ] }
我怎样才能循环通过它?
到目前为止得到的是:
NSError* error;
NSDictionary *JSON =
[NSJSONSerialization JSONObjectWithData: [(NSString *) message dataUsingEncoding:NSUTF8StringEncoding] options: NSJSONReadingMutableContainers
error: &error];
NSArray *messageArray = [JSON objectForKey:@"messageArray"];
// Parse and loop through the JSON
for (NSDictionary * dataDict in messageArray) {
NSString * messageID = [dataDict objectForKey:@"id"];
NSString * msgFrom = [dataDict objectForKey:@"msgFrom"];
NSString * msgTime = [dataDict objectForKey:@"msgDate"];
NSLog(@"FROM ---> %@", dataDict);
}