-
Notifications
You must be signed in to change notification settings - Fork 287
Open
Labels
Description
With FSharp.Data 3.3.3 (latest as of 31.12.2020) the following phenomenon can be observed:
#r "nuget: FSharp.Data,3.3.3"
open FSharp.Data
type PT = JsonProvider<"""{"k": [["foo", 1], ["bar", 2]] }""">
// expected: JsonProvider<...>.IntOrString [] []
// actual: JsonProvider<...>.IntOrString []
let sample = PT.GetSample().K
// string * int
let failsAtRuntime =
match sample with
| [| n; v |] -> n.String, v.Number // System.Exception: Expecting an array with single element at '/k[0]', got ["foo",1]
| _ -> failwith "Unexpected structure"
// (string * int) []
let ok =
sample
|> Array.map (fun k ->
match k.JsonValue.AsArray() with
| [| n; v |] -> n.AsString(), v.AsInteger()
| _ -> failwith "Unexpected structure")type PT = JsonProvider<"""{"k": [["foo", "bar"], ["other", "stuff"]] }"""> does not suffer from the same problem.
I'm willing to try and fix this myself, will get around to do this at earliest mid-October tough. Totally slipped my mind... hope to have another look soonish 😅