gpt4 book ai didi

swift - 字符串字典 :Any does not conform to protocol 'Decodable'

转载 作者:可可西里 更新时间:2023-11-01 00:20:27 34 4
gpt4 key购买 nike

<分区>

我正在尝试实现一个 Decodable 来解析 json 请求,但 json 请求在对象内部有一个字典。

这是我的代码:

    struct myStruct : Decodable {
let content: [String: Any]
}

enum CodingKeys: String, CodingKey {
case content = "content"
}

但是我收到了这个错误:

类型“MyClass.myStruct”不符合协议(protocol)“Decodable”

如何在不出现此错误的情况下将变量声明为字典?

非常感谢你的帮助

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com