ExCodable
ExCodable copied to clipboard
能支持[String: Any]和[Any]吗
https://github.com/levantAJ/AnyCodable https://stackoverflow.com/questions/44603248/how-to-decode-a-property-with-type-of-json-dictionary-in-swift-45-decodable-pr
可以考虑,等有空看一下。目前可以用 这个 变通实现。
我试着改了一下。 已经提交了一个合并申请。 大佬看看。
https://github.com/yxh265/ExCodable/tree/develop
支持模型定义如下:
struct testModel: ExAutoCodable {
@ExCodable
var jumpParam: [String: Any]? = [:]
@ExCodable
var matchs: [Any] = []
}
动手能力好强 👍🏿
但是把另一个框架的代码直接内置进来,并不是一个理想的选择,在同时使用这两个框架的 app 中会产生冲突。
建议通过组合的方式来达到同样的效果:ExCodable 提供了 ExCodableDecodingTypeConverter
协议,用来做自定义的类型转换。是否可以复用该协议,如有必要,对这个协议做适当的改造也是 OK 的。
因为另一个框架的代码它没做到pod,所以临时直接放进来了。 嗯,(ExCodable 提供了 ExCodableDecodingTypeConverter 协议)是个好方法,也期待你的更新。