我想将在线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)