title: decode Json string to class object Swift
body: <pre><code> private func createWeatherObjectWith(json: Data, x:Any.Type ,completion: @escaping (_ data: Any?, _ error: Error?) -&gt; 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)
          }
      }
  </code></pre>
  
  <p>Here I write above code to decode Json string to class object  by passing class type .But it gives the following error</p>
  
  <pre><code>Cannot invoke 'decode' with an argument list of type '(Any.Type, from: Data)'
  </code></pre>