“The data couldn’t be read because it is missing” error when decoding JSON in Swift

后端 未结 5 562
温柔的废话
温柔的废话 2021-01-31 07:20

I am getting the following error :

The data couldn’t be read because it is missing.

When I run the following code:

struct Indicator: Decodable {
         


        
5条回答
  •  北海茫月
    2021-01-31 08:08

    I just solved a similar issue on my end but for the property list decoder.

    The error in this case seems to mean that a key wasn't found and not the data as a whole.

    Try making the variables in your struct optional and it should return a nil value where the problem lies.

提交回复
热议问题