Skip to content
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

Auto-encoders in Thoth.Json and Thoth.Json.Net generate incompatible JSON for distriminated unions #82

Open
object opened this issue Oct 2, 2020 · 2 comments
Labels
bug Something isn't working
Milestone

Comments

@object
Copy link

object commented Oct 2, 2020

I reproduced this using versions of Thoth.Json 4.0 and Thoth.Json.Net 4.1.

This is an example of a JSON generated using Decode.Auto from a Fable app (Thoth.Json):

"Customer":["Verified",{"comparer":{},"tree":["MapOne","CustomerIdentity",{"Id":1,"PhoneNumber":"12345678"}]}]

Thoth.Json.Net fails to decode this string because it doesn't expect comparer node. If I serialize the same data using Thoth.Json.Net, it works fine:

"Customer":["Verified",{"CustomerIdentity":{"Id":1,"PhoneNumber":"12345678"}}]

@MangelMaxime MangelMaxime added the bug Something isn't working label Oct 2, 2020
@object
Copy link
Author

object commented Oct 2, 2020

Out of curiosity: is "comparer" element used in some scenarios? Looks like Thoth.Json.Giraffe/Thoth.Json.Net manage fine without it.

@MangelMaxime
Copy link
Contributor

Hello @object sorry for the delay

This is bug in Thoth.Json (Fable version) which kind of "stringify" the whole instance of a map.

I suppose you DUs looks similar to Verifier of Map<.., ...>

If you look at the instance of your map in memory you will an object with comparer and tree property.

As a workaround you can use manual decoder for now.

@MangelMaxime MangelMaxime added this to the Beyond milestone Jul 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants