-
Notifications
You must be signed in to change notification settings - Fork 413
Option to generate encoder/decoder for enum? #778
New issue
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
Comments
Maybe the generator can also reuse this generated function (like class Article {
State state;
...
} inside another file |
Also it would be great to have one place for setting @JsonEnumSerializable(unknownEnumValue: State.unknown)
enum State {
... which will be used as default in |
You can follow this. |
I have an idea for this, but we'll need to wait for Dart 2.14 |
Allows generating the associated helpers without requiring usage as a field in a @JsonSerializable class Fixes #778
WIP: #989 |
Allows generating the associated helpers without requiring usage as a field in a @JsonSerializable class Fixes #778
Is it possible to convert enum to json value? enum StatusCode {
@JsonValue(200)
success,
@JsonValue('500')
weird,
} Sometime, I want to display the |
Currently one can't decode/encode enum values directly from/to string.
For example, I have
and want to do this
I need either implement
stateFromString
manually (which will duplicate strings in @JsonValue) or make a wrapper class.It would be great to have an option to generate from/to string converters by some annotation, e.g.
The text was updated successfully, but these errors were encountered: