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

#161 Allow using single-case unions as dictionary keys #168

Merged
merged 2 commits into from
Aug 2, 2023

Conversation

Tarmil
Copy link
Owner

@Tarmil Tarmil commented Aug 2, 2023

For example:

open System.Text.Json
open System.Text.Json.Serialization

type CountryCode = CountryCode of string

let d = dict [
    CountryCode "fr", 1
    CountryCode "us", 2
]

JsonSerializer.Serialize(d, JsonFSharpOptions().ToJsonSerializerOptions())
// Returns: {"fr":1,"us":2}

Note: due to dotnet/runtime#77326, this requires System.Text.Json 8.0.

@Tarmil Tarmil merged commit 48cfa5b into master Aug 2, 2023
6 checks passed
@Tarmil Tarmil deleted the unions-as-dict-key branch August 2, 2023 20:24
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