问题描述
我坚持快速解码JSON。
我在一个带有10个字段的JSON的操场上获得了以下代码。当我尝试解码数据时,出现以下错误
error: Execution was interrupted,reason: EXC_BAD_ACCESS (code=EXC_I386_GPFLT).
The process has been left at the point where it was interrupted,use "thread return -x" to return to the state before expression evaluation.
但是如果我拿出例如“ ninth”和“ tenth”或任何其他字段中的2个,因此结构中仅剩下8个字段。
是否只能解码8个字段?我想念什么吗? 我有什么办法可以克服这个问题?
我的代码段:
let decoder = JSONDecoder()
struct Positions: Codable {
let first : String
let second: String
let third: String
let forth: String
let fith: String
let sixth: String
let seventh: String
let eigth: String
let nineth: String
let tenth: String
}
var positions = """
{
"first" : "first","second": "second","third": "third","forth": "forth","fith": "fith","sixth": "sixth","seventh": "seventh","eigth": "eigth","nineth": "nineth","tenth": "tenth"
}
""".data(using: .utf8)
let result = try decoder.decode(Positions.self,from: positions!)
print("tr \(result)")
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)