我有一个JSON文件,如下所示: here is a screenshot of my JSON file
我的代码是这样的:
guard let data = data else {
completionHandler(.failure(.missingResponseData))
return
}
guard let json = try? JSONSerialization.jsonObject(with: data, options: []),
let results = json["results"] as? [[String: Any]] else {
completionHandler(.failure(.invalidJson(message: "data does not contain an array of objects")))
return
}
do {
let movies = try results.map {
try Movie(json: $0)
}
completionHandler(.success(movies))
} catch let error as Error {
completionHandler(.failure(error))
} catch {
completionHandler(.failure(.other(error)))
}
但是我收到了这个错误:
类型'Any'没有下标成员
知道我做错了什么吗?