title: Leading zeros cut from JSON response when using enum
body: <p>Essentially I am using enum to account for instances where <code>code</code> is either and int or string - but it appears when the JSON value is simply an int with leading <code>0's</code> like <code>0039223</code> they get trimmed out. How can this be prevented?</p>
  <p>Try running this code in Playgrounds:</p>
  <pre><code>let data = &quot;&quot;&quot;
  [
    {
      &quot;date&quot;: &quot;2022-05-04&quot;,
      &quot;code&quot;: 0039223,
      &quot;notes&quot;: &quot;Take keys&quot;
    },
    {
      &quot;date&quot;: &quot;2022-05-04&quot;,
      &quot;code&quot;: &quot;Gate: 2312231&quot;,
      &quot;notes&quot;: &quot;Take Box&quot;
    }
  ]
  &quot;&quot;&quot;.data(using: .utf8)!
  
  enum Code: Decodable {
      case int(Int)
      case string(String)
  }
  
  struct Item: Decodable {
      var date: Date
      var code: Code
      var notes: String
  
      enum CodingKeys: String, CodingKey {
          case date, code, notes
      }
  
      init(from decoder: Decoder) throws {
          let container = try decoder.container(keyedBy: CodingKeys.self)
          self.date = try container.decode(Date.self, forKey: .date)
          self.notes = try container.decode(String.self, forKey: .notes)
  
          if let value = try? container.decode(Int.self, forKey: .code) {
              self.code = .int(value)
          } else if let value = try? container.decode(String.self, forKey: .code) {
              self.code = .string(value)
          } else {
              let context = DecodingError.Context(codingPath: decoder.codingPath, debugDescription: &quot;Unable to decode value for `code`&quot;)
              throw DecodingError.typeMismatch(Code.self, context)
          }
      }
  }
  
  let formatter = DateFormatter()
  formatter.dateFormat = &quot;yyyy-MM-dd&quot;
  
  let decoder = JSONDecoder()
  decoder.dateDecodingStrategy = .formatted(formatter)
  
  let items = try! decoder.decode([Item].self, from: data)
  
  for item in items {
      print(&quot;date: \(item.date.description)&quot;)
      print(&quot;code: \(item.code)&quot;)
      print(&quot;notes: \(item.notes)&quot;)
      print()
  }
  </code></pre>