我正在尝试使用 -objectForKey:
提取推文的第一个 url,我想知道如何一次性提取扩展的 url。
这是 json:
"entities":{
"hashtags":[
],
"symbols":[
],
"urls":[
{
"url":"http:\/\/t.co\/example",
"expanded_url":"http:\/\/example.com\/hi",
"display_url":"example.com\/hi",
"indices":[
46,
68
]
}
],
"user_mentions":[
]
},
这是我尝试过的:NSLog(@"URL FOUND: %@", [JSON objectForKey:@"entities/urls/expanded_url"]);
但我得到了 (null
)。
最佳答案
这段代码对你有帮助
NSArray *urls = [[JSON objectForKey:@"entities"] objectForKey:@"urls"];
NSString *url = [[urls objectAtIndex:0] objectForKey:@"url"];
NSLog(@"%@",url);
关于iOS:使用 JSON 的 Twitter URL 路径?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20810911/