We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
struct CustomAdapterAAA: JSONAdapter { public func adapt(_ decoder: CleanDecoder) throws -> String { return "default string" } } 这个方法可以给这个decoder解析出来的所有string设置默认值,想问下,可以给key设置单独的默认值么,比如说一个model里有strA,想要默认值是“strA” strB,想要默认值是“strB” 支持这样单独设置默认值么?
The text was updated successfully, but these errors were encountered:
@Pircate 大佬,实际项目中确实有很多这样的需求,model模型中同类型(例如字符串类型)的字段,有多个。但是我们想对不同的字段,单独设置不同的默认值。麻烦看看,有什么巧妙的办法?
Sorry, something went wrong.
我这边研究了一下,可以参考这个资料: https://juejin.cn/post/6974762996077690910 对于我们开发人员来说,就是需要在使用上简单、代码量少。😄 @Pircate
你可以配合这个属性包装器一起使用的
No branches or pull requests
struct CustomAdapterAAA: JSONAdapter {
public func adapt(_ decoder: CleanDecoder) throws -> String {
return "default string"
}
}
这个方法可以给这个decoder解析出来的所有string设置默认值,想问下,可以给key设置单独的默认值么,比如说一个model里有strA,想要默认值是“strA”
strB,想要默认值是“strB”
支持这样单独设置默认值么?
The text was updated successfully, but these errors were encountered: