簡體   English   中英

iPhone中解析JSON響應時出現問題

[英]problem in parsing JSON response in iphone

我正在從此鏈接獲取json數據

現在我要從“ html_instructions”中獲取數據:part

NSDictionary *result = [stringtext JSONValue];
NSLog(@"here");
NSArray *resultarr = [result objectForKey:@"routes"];
NSString *string;

for(NSDictionary *di in resultarr){
    NSLog(@"for loop");
    string = [[di objectForKey:@"legs"] objectForKey:@"steps"];
}

但是在控制台中打印“ for loop”后,它將引發異常

2011-05-20 16:16:26.997 speedymap[759:207] -[__NSArrayM objectForKey:]: unrecognized selector sent to instance 0x62a7d60

2011-05-20 16:16:26.999 speedymap[759:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayM objectForKey:]: unrecognized selector sent to instance 0x62a7d60'

請幫我,我想要html_instructiuons字段值

檢查resultarrdi真的包含任何東西。

NSDictionary *result = [stringtext JSONValue];
NSLog(@"here");
NSArray *resultarr = [result objectForKey:@"routes"];
CFShow(resultarr);
NSString *string;

for(NSDictionary *di in resultarr){
    CFShow(di);
    NSLog(@"for loop");
    NSArray *tempArr = [[di objectForKey:@"legs"] objectForKey:@"steps"];
}

http://jsonviewer.stack.hu/#http://maps.googleapis.com/maps/api/directions/json?origin=delhi&destination=noida&waypoints=&sensor=true

檢查查看器並相應地設置值。 [di objectForKey:@“ legs”]返回一個數組。 該數組的第一個對象是具有關鍵步驟的字典。 但這也返回另一個數組。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM