-
-
Notifications
You must be signed in to change notification settings - Fork 100
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
Custom decoding for sealed traits with discriminator #1242
Comments
Decode function fails since it's decoding invalid JSON because it has some trailing |
Why do you need |
|
Have you tried to derive codecs with JsonCodecMaker.make(CodecMakerConfig.withDiscriminatorFieldName(Some("discriminator")).withRequireDiscriminatorFirst(false)) and check if works for you? |
I'll use an example I have that works:
the problem is that I would like to build a tooling around it which I tried to show an example that's nearly working in the first post. |
Why do you need tooling? |
I want to make a more high-level API that supports my use case, and my fellow programmers can just use that tooling which does the heavy lifting for them.
examples
or there may be additional fields for example:
examples
|
Am I understand right that your JSON representation cannot be changed to something like: {
"DATA": {
"age": 20,
"name": "John",
"surname": "Doe"
},
"revision": 10
} or {
"payload": {
"type": "DATA",
"age": 20,
"name": "John",
"surname": "Doe"
},
"revision": 10
} ? |
Yes, that's right since I'm not the one creating them. |
I'm strongly recommend switching to 1st (the most safe and performant) or 2nd option. It will reduce runtime and maintenance costs, eliminate present and future challenges. |
I agree with you, but I can't just go and rewrite all legacy codebase to the 1st variant, and since I want to support it I lack the tooling around the case I've described above. Side note I'm using the 1st option in new applications. |
Hi I would like to ask you for your opinion on problem I've encountered. I'll try to be as brief as possible.
I want to build a tooling that will be able to create a
JsonValueCodec[ApiDTO]
I've come up with this solution which I can't make work because of the closing bracket at the end. (T <=> MyTrait, ? <=> {Foo, Bar, ...})
The text was updated successfully, but these errors were encountered: