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

Add new UnionMode #58

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Add new UnionMode #58

wants to merge 2 commits into from

Conversation

dtymakhov
Copy link

I added a new AsValue to the UnionMode. This will be useful when the field can be one of a type, such as a int or a string. But this cannot be deserialised.

For example:

  [<JsonUnion(Mode = UnionMode.AsValue)>]
    type AsValueUnion =
    | StringCase of string
    | IntCase of int

    type RecordWithAsValueUnion = {
        StringValue : AsValueUnion
        IntValue : AsValueUnion
    }

  let record = { StringValue = StringCase "String"; IntValue = IntCase 1 }

will be serialised like a {"StringValue":"String","IntValue":1}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant