小编Bre*_*mte的帖子

debugDescription:“预期对Array <Any>进行解码,但找到了字典。”,底层错误:无)

我想将在线json文件加载到我的应用程序中,但是遇到了以下错误:

typeMismatch(Swift.Array,Swift.DecodingError.Context(codingPath:[],debugDescription:“预期对Array进行解码,但找到了字典。”,底层错误:无))

我已经看过stackoverflow,但是其他解决方案并没有帮助解决我的问题。

我的json

我的数据模型:

import Foundation

struct Initial: Codable {
    let copyright: String
    let totalItems: Int
    let totalEvents: Int
    let totalGames: Int
    let totalMatches: Int
    let wait: Int
    let dates: [Dates]
}

struct Dates: Codable {
    let date: String
    let totalItems: Int
    let totalEvents: Int
    let totalGames: Int
    let totalMatches: Int
    let games: [Game]
}

struct Game: Codable {
    let gamePk: Int
    let link: String
    let gameType: String
    let season: String
    let gameDate: String
    let status: Status
    let …
Run Code Online (Sandbox Code Playgroud)

json struct swift decodable

2
推荐指数
2
解决办法
5551
查看次数

标签 统计

decodable ×1

json ×1

struct ×1

swift ×1