FSharp.Data
FSharp.Data copied to clipboard
JSON constructors create values that don't correspond to the original schema
The constructors provided by JsonProvider can create values in a way that doesn't correspond to the original schema. In particular:
-
Optional fields are serialized as
nullrather than absent field:type A = JsonProvider<"""[{"a":1,"b":2}, {"a":3}]"""> let a = A.Root(a = 1, b = None).JsonValue.ToString() // Expected: {"a":1} // Actual: {"a":1,"b":null} -
Decimal fields inferred from string are serialized as number:
type B = JsonProvider<"""{"a":"1.4"}"""> let b = B.Root(a = 3.1m).JsonValue.ToString() // Expected: {"a":"3.1"} // Actual: {"a":3.1}
Same problem here for option an json strings (double quotes surrounded values)
Same problem on #1245