Noticed this issue when using ThothLike().WithSkippableOptionFields() however a minimal repro can be achieved with WithSkippableOptionFields() alone.
Repro:
open System.Text.Json
open System.Text.Json.Serialization
let opts = JsonFSharpOptions().WithSkippableOptionFields().ToJsonSerializerOptions()
type MyUnion =
| Case1 of int option
| Case2 of bool option
type MyRecord = { Field1: MyUnion }
let json = JsonSerializer.Serialize({ Field1 = Case1 None }, opts)
let value = JsonSerializer.Deserialize<MyRecord>(json, opts)
Throws exception:
Unhandled exception. System.Text.Json.JsonException: The JSON value could not be converted to System.Int32. Path: $ | LineNumber: 0 | BytePositionInLine: 4.
---> System.InvalidOperationException: Cannot get the value of a token type 'Null' as a number.
Noticed this issue when using
ThothLike().WithSkippableOptionFields()
however a minimal repro can be achieved withWithSkippableOptionFields()
alone.Repro:
Throws exception: