Open mrdziuban opened 2 months ago
Thanks, @mrdziuban, for this proposal.
I was thinking about the distinction between enum
instances and singleton objects myself.
Conceptionally they are pretty much the same but technically they are very different, which case objects
defining their own type extending Product0
while enum
cases simply being instances of their enum
type.
If we were to implement the option you are asking for it'd have to be opt-in configurable, since we can't break existing encodings. One way could be to add a enumCasesAsProduct
flag to AdtEncodingStrategy
.
Would sth like that work for you?
Yeah a new config option on AdtEncodingStrategy
would be great, thank you!
Hi, thank you for this great library!
I'm curious if you would consider adding an option to always derive
enum
s as if they weresealed trait
s/sealed abstract class
es? That is, even a simpleenum
with only singletoncase
s would still produce a JSON object and could be configured withAdtEncodingStrategy
.For example:
I would like
Json.encode(Foo.Bar)
to produce{"Baz":{}}
so I can useenum
s andsealed trait
s interchangeably