iOS:使用 JSON 的 Twitter URL 路径?

标签 ios objective-c json twitter twitter-streaming-api

我正在尝试使用 -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/

相关文章:

objective-c - 如何确保 Cocoa 中的窗口只显示一次?

iphone - 用黑色矩形覆盖屏幕吗?

javascript - 使用 $.getJSON 的问题

javascript - ReactJS componentWillMount 在 render 方法之后运行

Javascript stringify '%%' 丢失百分号

ios - Swift 中的卷积 CIFilter

ios - 使用自动布局时如何在加载时滚动 UIScrollView

ios - ibeacons 和地理围栏结合 swift

ios - CMSampleBufferGetImageBuffer 中的内存泄漏

iphone - 将核心数据与 NSMutableArray 同步