debugDescription: “Expected to decode Array but found a dictionary instead.”, underlyingError: nil)

前端 未结 3 670
粉色の甜心
粉色の甜心 2021-01-13 06:48

I want to load an online json file into my application, but I am running into this error:

typeMismatch(Swift.Array, Swift.DecodingError.Context(codi

3条回答
  •  盖世英雄少女心
    2021-01-13 07:14

    The JSON is represented by your Initial struct, not an array of Dates.

    Change:

    let jsondata = try decoder.decode([Dates].self, from: detailData)
    

    to:

    let jsondata = try decoder.decode(Initial.self, from: detailData)
    

提交回复
热议问题