【发布时间】:2016-08-30 21:33:47
【问题描述】:
我是 iOS 开发新手。我正在尝试将 JSOn 数组值转换为 Objective-C 值。我的 JSON 值是这样的:
{"result":
[{"alternative":
[{"transcript":"4"},
{"transcript":"four"},
{"transcript":"so"},
{"transcript":"who"}],
"final":true}],
"result_index":0}
我试过这样:
NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:speechrequestString]];
NSError *error;
NSDictionary *speechResult= [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&error];
NSArray *speechArray= [speechResult valueForKey:@"result"];
NSLog(@"%@",speechArray);
NSLog(@"Response is of type: %@", [speechArray class]);
speechArray 始终为空。如何解决这个问题?
同时我想打印transcript 值。
【问题讨论】:
-
speechArray 值总是打印空值。谢谢@Avi
标签: ios objective-c json nsarray