Closed SuricateTrading closed 1 year ago
When serializing a dynamic field containing an enum, the error "Converting object to an encodable object failed" occurs.
Example:
@JsonSerializable() class MyClass{ dynamic field; }
@JsonEnum() enum MyEnum{ @JsonValue(0) top, @JsonValue(1) middle, }
void main() { MyClass() ..field = MyEnum.top ..myClass.toJson(); }
By design. We NEED the type info to do any type of conversion. dynamic (or Object, etc) only works with values that are already JSON-compatible.
dynamic
When serializing a dynamic field containing an enum, the error "Converting object to an encodable object failed" occurs.
Example:
@JsonSerializable() class MyClass{ dynamic field; }
@JsonEnum() enum MyEnum{ @JsonValue(0) top, @JsonValue(1) middle, }
void main() { MyClass() ..field = MyEnum.top ..myClass.toJson(); }