小编Dom*_*ski的帖子

Swift.DecodingError.Context

我正在解码来自 URL 响应的 JSON(解码器)字符串,如下所示,并在解码过程中得到以下错误消息:

错误:

typeMismatch(Swift.String, Swift.DecodingError.Context(codingPath: [_JSONKey(stringValue: "Index 0", intValue: 0), CodingKeys(stringValue: "tags", intValue: nil), _JSONKey(stringValue: "Index 0") , intValue: 0)], debugDescription: "预期解码字符串,但找到了一个数字。",underlyingError: nil))

结构:

struct Wordpress: Codable {
    let id: Int?
    let date: String?
    let date_gmt: String?
    let guid: GUID?
    let modified: String?
    let modified_gmt: String?
    let slug: String?
    let status: String?
    let type: String?
    let link: String?
    let title: Title?
    let content: Content?
    let excerpt: Excerpt?
    let author: Int?
    let featured_media: Int?
    let comment_status: String?
    let ping_status: …
Run Code Online (Sandbox Code Playgroud)

swift codable

1
推荐指数
1
解决办法
668
查看次数

标签 统计

codable ×1

swift ×1