Convert decode.field to decode.optional_field code action #5481
Closed
folospior
started this conversation in
Ideas & suggestions
Replies: 2 comments
-
|
Hello! Please use discussions for proposals, issues are for actionable work and bugs. |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
Looks like this is a duplicate: #5082 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
The
Generate dynamic decodercode action is great, but one thing that I feel it's been lacking at is optionals.Currently, this type:
will have this decoder generated:
However, Options can be used to represent two states (JSON examples):
{}null:{"wobble": null}The decoder above will fail in case it can't find the
wobblefield. Because of that, the code decoding the field has to be changed, such that it usesdecode.optional_field:How I've been personally dealing with this issue is via macros. There a few issues associated with that, compared to a code action:
What I suggest to mitigate this is a code action,
Convert to optional_field, which, when ran, will convert the code from the first example into the code from the second example.Beta Was this translation helpful? Give feedback.
All reactions