所以我想获取一个JSON文件,这个文件位于:http://online.basket.ee/s2/list/2017-03-01/data.json
它看起来不像RESTful应用程序接口,所以我有点困惑。
let tron = TRON(baseURL: "http://online.basket.ee")
class JSONError: JSONDecodable {
required init(json: JSON) throws {
print("JSON ERROR")
}
}
fileprivate func fetchTodayFeed() {
let request: APIRequest<TodayDS, JSONError> = tron.request("/s2/list/2017-03-01/data.json")
request.perform(withSuccess: { (todayDatasource) in
print("Succesfully fetched our JSON object")
self.datasource = todayDatasource
}) { (err) in
print("Failed to fetch JSON", err)
}
}我以同样的方式从我自己的JSON中获取JSON,它是我使用Node.js和RESTful创建的。
所以我的问题是,是否有可能获取这种JSON,或者我做错了什么。
发布于 2017-03-02 09:04:08
这对我很管用。试一试
let tron = TRON(baseURL: "http://online.basket.ee/s2/list/2017-03-01")然后
let request : APIRequest<Source,JSONError> = tron.request("data.json")如果你想使用像"https://example.com/blabla?id=test“这样的url,你必须这样做
let tron = TRON(baseURL: "https://example.com")
let apiRequest : APIRequest<SourceJSON,JSONError> = tron.request("blabla")
daysLeftRequest.method = .get
daysLeftRequest.parameters = ["id":"test"]https://stackoverflow.com/questions/42543898
复制相似问题