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
normal case:
{ "maintenance": true } { "maintenance": false }
If there is no maintenance station then it will become empty string
empty string
{ "maintenance": "" }
i want to have nil if maintenance is empty string in json
nil
struct Demo: Codable { var maintenance: Bool? }
Is there a good way to do it?
The text was updated successfully, but these errors were encountered:
I think something like this should work, no testing done though:
struct NilBoolFallback: FallbackValueProvider { public static var defaultValue: Bool? { nil } } @FallbackDecoding<NilBoolFallback> var maintenance: Bool?
The idea being if it's anything other than a Bool (and thus fails to decode) it will use the defaultValue
Sorry, something went wrong.
@WingCH Re-open if you have any more questions
No branches or pull requests
normal case:
If there is no maintenance station then it will become
empty string
i want to have
nil
if maintenance is empty string in jsonIs there a good way to do it?
The text was updated successfully, but these errors were encountered: