title: Swift problems parsing JSON
body: <p>I would like to make a mini app with pokeapi which contains the pokemon.</p>
  <p>I'm having a lot of problems parsing this particular JSON, the data doesn't come out in the TableView.</p>
  <p>This is website: <a href="https://pokeapi.co/docs/v2#info" rel="nofollow noreferrer">https://pokeapi.co/docs/v2#info</a></p>
  <p>In the press console:
  typeMismatch(Swift.Array, Swift.DecodingError.Context(codingPath: [], debugDescription: &quot;Expected to decode Array but found a dictionary instead.&quot;, underlyingError: nil))</p>
  <hr />
  <p>Below is my code:</p>
  <p>DataManager.swift</p>
  <pre><code>import UIKit
  
  
  protocol DataManagerDelegate {
     func didUpdateStruct(_ dataManager: DataManager, dataModel: [DataModel])
     func didFailWithError(error: Error)
  }
  
  
  struct DataManager {
      
  let baseURL = &quot;https://pokeapi.co/api/v2/pokemon&quot;
      
  var delegate: DataManagerDelegate?
      
  func fetchUrl() {
          
  let urlString = &quot;\(baseURL)&quot;
          
  performRequest(with: urlString)
          
  }
      
  
  
  func performRequest(with urlString: String) {
          
  if let url = URL(string: urlString) {
              
  let session = URLSession(configuration: .default)
              
  let task = session.dataTask(with: url) { (data, response, error) in
  
  if error != nil {
                      
  self.delegate?.didFailWithError(error: error!)
                      
  return
                      
  }
                  
  
  if let safeData = data {
                      
  if let pokemons = self.parseJSON(safeData) {
                          
  self.delegate?.didUpdateStruct(self, dataModel: pokemons)
                          
                      }
                      
                  }
                  
              }
              
              task.resume()
              
          }
          
      }
      
  
  
      func parseJSON(_ dataModel: Data) -&gt; [DataModel]? {
  
          let decoder = JSONDecoder()
          
       do {
              
       let decodedData = try decoder.decode([DataModel].self, from: dataModel)
              
              return decodedData
              
          } catch {
  
              delegate?.didFailWithError(error: error)
  
              return nil
              
          }
          
      }
  
  }
  </code></pre>
  <p>DataModel.swift</p>
  <pre><code>import UIKit
  
  struct DataModel: Codable {
      
      let results: [Results]
   
  }
  
  struct Results: Codable {
  
      let name: String?
  
  }
  </code></pre>