You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When encoding toJson and using @jsonDiscriminator("type") on sealed traits the output string does not have type field as expected. In this example BarNotOk is expected to parse, but does not with error (missing hint 'type').
BarNotOk uses derives JsonCodec and is expected to add type field when encoding/decoding, but encoding is not working as expected and the type field is not added when running toJson.
BarOk uses a work-around to get the expected behaviour, specifying a custom encoder that explicitly adds the type field. This has the expected behaviour but requires extra work-around code.
When encoding
toJson
and using@jsonDiscriminator("type")
on sealed traits the output string does not havetype
field as expected. In this exampleBarNotOk
is expected to parse, but does not with error(missing hint 'type')
.BarNotOk
usesderives JsonCodec
and is expected to addtype
field when encoding/decoding, but encoding is not working as expected and thetype
field is not added when runningtoJson
.BarOk
uses a work-around to get the expected behaviour, specifying a custom encoder that explicitly adds thetype
field. This has the expected behaviour but requires extra work-around code.Output:
Expected output:
The text was updated successfully, but these errors were encountered: