title: Difficulty parse integer value in JSON using JSON Decoder in Swift
body: <p>I am trying to decode some JSON from an API that looks like this (foo is short for a list of properties):</p>
  <pre><code>{&quot;page&quot;:1,&quot;total_results&quot;:10000,&quot;total_pages&quot;:500,&quot;results&quot;:[{&quot;foo&quot;:&quot;bar&quot;},{&quot;foo&quot;:&quot;bar2&quot;},{&quot;foo&quot;:&quot;bar3&quot;}]}
  </code></pre>
  <p>The struct recommended by quicktype.io which looks correct to me too is:</p>
  <pre><code>struct ObjectsReturned: Codable {
      let page, totalResults, totalPages: Int
      let results: [Result]
  
      enum CodingKeys: String, CodingKey {
          case page
          case totalResults = &quot;total_results&quot;
          case totalPages = &quot;total_pages&quot;
          case results
      }
  }
  
  // MARK: - Result
  struct Result: Codable {
      let foo: String
  }
  </code></pre>
  <p>However, when I try to decode, although it is able to handle page, it throws an error on total_results as follows:</p>
  <blockquote>
  <p>typeMismatch(Swift.Dictionary&lt;Swift.String, Any&gt;,
  Swift.DecodingError.Context(codingPath:
  [_DictionaryCodingKey(stringValue: &quot;total_results&quot;, intValue: nil)],
  debugDescription: &quot;Expected to decode Dictionary&lt;String, Any&gt; but
  found a number instead.&quot;, underlyingError: nil))</p>
  </blockquote>
  <p>What could be the reason for this error and how can I fix it?</p>
  <p>Thanks for any suggestions.</p>
  <p>Note:</p>
  <p>Decoding is via:</p>
  <pre><code>do {
                              let mything = try JSONDecoder().decode([String:ObjectReturned].self, from: data)
                          } catch {
                              print(error)
                          }
  </code></pre>