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.
For example:
Note: due to dotnet/runtime#77326, this requires System.Text.Json 8.0.