-
Notifications
You must be signed in to change notification settings - Fork 48
Open
Description
Сan FSharp.SystemTextJson work with case like this when I have only 1 letter or not full word and I want to return
Example:
in json I have "Mail" or "m"
and I want to return Comunication.Mailing
open System
open System.Text.Json
open System.Text.Json.Serialization
[<JsonFSharpConverter(JsonUnionEncoding.FSharpLuLike)>]
type Comunication =
| [<JsonName"MAILING">] Mailing
| [<JsonName "STANDART>] Standart
type Robot = {
Code : int
Model : Comunication
}
[<EntryPoint>]
let main args =
let r2d2 = { Code = 123; Model = AddressType.Mailing }
let x = JsonSerializer.Deserialize<Robot>( """{"Code":123,"Model":"M"}"""
0
[]
let **should return Mailing** () =
Assert.Equal(r2d2, JsonSerializer.Deserialize( """{"Code":123,"Model":"M"}""", options))
Metadata
Metadata
Assignees
Labels
No labels