private func createWeatherObjectWith(json: Data, x:Any.Type ,completion: @escaping (_ data: Any?, _ error: Error?) -> Void) {
do {
let decoder = JSONDecoder()
decoder.keyDecodingStrategy = .convertFromSnakeCase
let weather = try decoder.decode(x.self, from: json)
return completion(weather, nil)
} catch let error {
print("Error creating current weather from JSON because: \(error.localizedDescription)")
return completion(nil, error)
}
}
Here I write above code to decode JSON string to class object by passing class type. But it gives the following error
Cannot invoke 'decode' with an argument list of type '(Any.Type, from: Data)'