The JSON Provider, iirc like others, infers a boolean data type from yes or no strings (case insensitive).
However, the boolean representation as a yes/no string is not preserved, and generating a new JSON string via .ToString() will contain a JSON true/false field, which won't typically be compatible with the original JSON payload.
Repro script:
#r "nuget: fsharp.data"
open FSharp.Data
type Yes = JsonProvider<""" { "Foo" : "Yes" } """>
let yes = Yes.Root(foo = true)
printfn "%O" yes
(*
{
"Foo": true
}
*)
Workaround : Use the InferTypesFromValues = false parameter and disable type inference entirely.
The JSON Provider, iirc like others, infers a boolean data type from
yes
orno
strings (case insensitive).However, the boolean representation as a yes/no string is not preserved, and generating a new JSON string via
.ToString()
will contain a JSONtrue
/false
field, which won't typically be compatible with the original JSON payload.Repro script:
Workaround : Use the
InferTypesFromValues = false
parameter and disable type inference entirely.