-
Notifications
You must be signed in to change notification settings - Fork 39
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
Support single-case discriminated union #71
Comments
Or is FSharpLu.Json abandoned? What should I use instead? Newtonsoft is 100% useless – it doesn't even encode |
Could be easily added, why not send a PR. (Note I'm not a maintainer and have fixed similar things in the lib) |
I've actually hacked together a fix locally based on the source code of this library. I might need to do some refactoring, but I could try to make a PR out of it when I get the time. |
@drhumlen Project is still maintained and is open to suggestion/PR. |
It would be nice if single-case discriminated unions was serialized directly:
instead of
Edit: I realize there's some cases where this will do something very different from what's intended; e.g. if you have
With the intention of adding more cases in the future, and then you'll break the serializer when you add the next case.
So I'm propising that we only do the single-case DU "optimization" when: There's one and only one case of course, and that case only has 1 field(?), and one or both of the following:
type UserId = UserId of string
. If it'stype UserId = PersonId of string
, then that's a no-match. (?)I think I like 1 more, even though it's slightly more "magical", but I think it's most pragmatic way of doing it. What do you think?
The text was updated successfully, but these errors were encountered: