- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我正在尝试从“https://maps.googleapis.com/maps/api/place/nearbysearch/json?”获取 JSON 到(swift 3)带有数组的 tableView Controller 。但是从 google api 返回的数据是字典和放在 tableView 上的错误我应该如何处理我的代码?
任何答案都会有帮助
这是我的代码:
var listData : [[String : AnyObject]] = [[String : AnyObject]]()
override func viewDidLoad() {
super.viewDidLoad()
self.tableView.dataSource = self
self.tableView.delegate = self
let myURL : URL = URL(string: "https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=13.88068,100.43575&radius=300&type=gas_station&key=YOURKEY")!
Alamofire.request(myURL).responseJSON(completionHandler: {
response in
switch response.result{
case .success:
self.listData = response.result.value as! [[String : AnyObject]]
print(self.listData.description)
self.tableView.reloadData()
case .failure(let error):
print(error)
}
})
最佳答案
您正在将结果转换为一个数组(更准确地说,是一个字典数组)。但响应不是数组。它是一本字典。但是与其 results
键关联的值是一个字典数组:
var listData = [[String: Any]]()
override func viewDidLoad() {
super.viewDidLoad()
tableView.dataSource = self
tableView.delegate = self
let url = URL(string: "https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=13.88068,100.43575&radius=300&type=gas_station&key=YOURKEY")!
Alamofire.request(url).responseJSON { response in
switch response.result {
case .success(let value):
guard let json = value as? [String: Any], let listData = json["results"] as? [[String: Any]] else {
print("Response does not contain results")
return
}
self.listData = listData
print(listData)
self.tableView.reloadData()
case .failure(let error):
print(error)
}
}
}
关于json - 如何快速从 "https://maps.googleapis.com/maps/api/place/nearbysearch/json? "获取 JSON 到数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47015725/
我正在使用DART构建一个后端服务器。。由于dart没有任何firebase admin sdk,我使用GoogleAPIS来与firebase交互。。对于Firebase认证,我看到它和Google
我需要将图像上传到 Firebase 存储并获取要使用的下载 URL 作为 src对于 我的网络应用程序中的标签。 当我使用 firebase 将图像从浏览器上传到我的存储桶时客户端 SDK,这就是我
我是 GCP 的新手,我正在尝试通过 Terraform 启用一些 API。 variable "gcp_service_list" { description ="Projectof apis"
我的意图: 我想调用 Google 日历的 API acl.list()来自google script使用 UrlFetchApp.fetch()功能。 问题: 我的 Google 脚本在运行时自身具
以下问题:我试图通过 Google Books API 获取信息,我发现 this Example ,但是如果我执行它,它会出现以下错误。 java.net.UnknownHostException:
几天以来,youtube.googleapis.com似乎完全崩溃了。 直到那一刻,嵌入视频(如https://youtube.googleapis.com/v/dQw4w9WgXcQ)都没有问题。目
已经实现了 oauth2.0 并使用范围进行了握手: "https://www.googleapis.com/auth/userinfo.email ", "https://www.googleapi
已实现 oauth2.0 并使用范围完成握手: "https://www.googleapis.com/auth/userinfo.email ", "https://www.googleapis.c
我的用户登录到我的应用程序,应用程序将 idtoken 发送到我的服务器,服务器将请求发送到谷歌,谷歌将用户数据发送到我的服务器,服务器将其放入我的数据库中。工作了 5 个月。现在: 如果我在我的网络
我正在尝试构建一个使用来自以下网址的数据的应用程序:http://ajax.googleapis.com/ajax/services/feed/load?v=1.0&num=8&q=http%3A%2
使用googleapi时出错 我的错误: (node:7776) UnhandledPromiseRejectionWarning: TypeError: Cannot destructure pro
我正在使用 googleapis 服务获取用户的位置、当前城市名称 + 国家/地区名称: NSString *urlString = [NSString stringWithFormat:@"http
对于新手问题,我深表歉意,因为我是 Android 设备开发的新手(2 天前开始开发)。 不过我明白,要使用谷歌地图的定位服务,当您创建一个项目并且 eclipse 提示您输入 SDK 目标时,您应该
这是我的代码: var http = require('http'); var express = require('express'); var Session = require('express
我有一个应用程序想要嵌入谷歌地图,并且需要将 key 放入配置文件中。所以这就是我所做的: 在 config.js 中 GOOGLE_MAP_KEY = "mykeyofgoogleapi"; 在 i
安装 googleapis pod 时出现错误“没有找到 googleapis 的 podspec。” 我正在尝试安装 pod 'googleapis', :path => '.'但是,它出现以下错误
需要帮助..!我正在研究 Android Transliteration,我的代码中出现以下 3 个错误。 1)GoogleAPI cannot be resolved 2)Translate can
我正在尝试在 Freebase 上查询所有美国县及其地理位置(经度 + 纬度)。我注意到有时查询会起作用,但在其他尝试中它会返回以下内容:。 我尝试更改查询结果限制,但我发现查询失败的限制有所不同;有
我正在学习一个涉及 GoogleMaps API JS 的教程,一切顺利。在尝试构建我自己的应用程序时,我遇到了显示路线的问题。我正在处理的应用程序主要是用 ruby on rails 编写的。
我正在尝试从 .proto 文件编译 GoogleCloudSpeechToTextv1p1beta1 的 C# 库 here . protobuf 编译器可以工作,只是它缺少 googleapis/
我是一名优秀的程序员,十分优秀!