What Is Preventing My Conversion From String to Int When Decoding Using Swift 4’s Codable?

前端 未结 2 1999
面向向阳花
面向向阳花 2020-12-21 08:08

I am getting the following JSON back from a network request:

{
    \"uvIndex\": 5
}

I use the fol

2条回答
  •  眼角桃花
    2020-12-21 08:44

    You could try SafeDecoder

    import SafeDecoder
    
    internal struct CurrentWeatherReport: Codable {
    
      internal var uvIndex: Int?
    
    }
    

    Then just decode as usual.

提交回复
热议问题