【发布时间】:2020-06-26 10:53:11
【问题描述】:
我正在尝试为下面的 JSON 编写一个 Swift Codable 模型。
{
"batchcomplete": "",
"query": {
"pages": {
"26667" (The problem is here): {
"pageid": 26667,
"ns": 0,
"title": "Spain",
"contentmodel": "wikitext",
"pagelanguage": "en",
"pagelanguagehtmlcode": "en",
"pagelanguagedir": "ltr",
"touched": "2020-03-14T18:03:48Z",
"lastrevid": 945549863,
"length": 254911,
"fullurl": "https://en.wikipedia.org/wiki/Spain",
"editurl": "https://en.wikipedia.org/w/index.php?title=Spain&action=edit",
"canonicalurl": "https://en.wikipedia.org/wiki/Spain"
}
}
}
}
问题是每次我查询时都会更改其中一个键。 将上述JSON中的标记为(问题出在这里)
如何用JSONDecoder解析上述JSON文件?
这可以使用 SwiftyJSON 等库轻松解析。
【问题讨论】:
标签: ios json swift jsondecoder