FSharp.Json
FSharp.Json copied to clipboard
Deserialize union in CaseKeyAsFieldValue mode from JSON with more than 2 fields
Is there any particular reason for this check in deserializeUnion
?
if fields.Length <> 2 then
failDeserialization path <| sprintf "Failed to parse union from record with %i fields, should be 2 fields." fields.Length
I have a JSON with more than two fields but I care just for the key field (union case discriminator) and the value field.
{
"ignore_this": "yes",
"ignore_that": "also yes",
...,
"discriminator": "type_1",
"data": {
...
}
}
Does data
in your example depend on discriminator
? You refer to some "value field" that is not in your example (I'm assuming you meant data
field).
Yes, sorry, data
is the value field (CaseValueField = "data"
).
Hmmm, actually from the code it seems that we can safely lift this limitation for number of fields in the object.
Thank you I will let you know here in what release the change is available
Thanks!