-
Notifications
You must be signed in to change notification settings - Fork 44
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
Add support for different encodings for unions #6
Comments
I would propose adding another option called
The motivation is when serializing Unions that represent a series of simple codes. |
That's a great idea! |
That's great to have a choice. But I don't need it for Options. its a special case from my sight. Should be just serialized to value inside of |
I think the best would be to do what you propose by default (ie |
Agree, though that's their fault if they model option of option or list of option, etc. :) |
Closing as this was released in v0.4 (the union issue is handled in #16). |
The current encoding for a value such as:
is what we can call Newtonsoft-like:
I propose we add encoding formats like so:
This would give the following formats:
AdjacentTag
: Newtonsoft-like.AdjacentTag ||| NamedFields
:ExternalTag
:ExternalTag ||| NamedFields
:InternalTag
: Thoth-like.InternalTag ||| NamedFields
: WebSharper-like.Untagged
: includes theNamedFields
bit, sinceUntagged
with unnamed fields doesn't really make sense. Deserialization is only possible if all cases have differently named fields and there's only one nullary case.The naming is shamelessly stolen from Rust's serde.
Note that when a field doesn't have an explicit name, F# automatically assigns the name "Item" if there is only one field, or "Item1", "Item2", etc if there are several fields.
The question of customizing the names of the fields "Case" and "Fields" should be resolved separately.
The text was updated successfully, but these errors were encountered: