且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

“由于缺少数据,因此无法读取数据"在Swift中解码JSON时出错

更新时间:2022-12-08 10:26:18

我刚刚解决了一个类似的问题,只是针对属性列表解码器.

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.

尝试使结构中的变量为可选,它应该在问题所在的地方返回nil值.

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