I have a json document like this:
{ "index": 1, "addressOne": "1506 WAKE FOREST RD ", "addressTwo": "RALEIGH NC 27604-1331", "addressThree": " ", "assessedValue": "$34,848", "id": "c0e931de-68b8-452e-8365-66d3a4a93483", "_rid": "pmVVALZMZAEBAAAAAAAAAA==", "_ts": 1423934277, "_self": "dbs/pmVVAA==/colls/pmVVALZMZAE=/docs/pmVVALZMZAEBAAAAAAAAAA==/", "_etag": "\"0000c100-0000-0000-0000-54df83450000\"", "_attachments": "attachments/" }
I then load it via the type provider like this:
type HouseValuation = JsonProvider<"../data/HouseValuationSample.json">
When I try and use the HouseValuation as part of an argument, it is cast back to Object:
What am I doing wrong?
Thanks in advance
The type HouseValuation
is a root type that is used just to host the Parse
and Load
methods, but it is not a type that represents the actual parsed document. If you look at the type of Load
or Parse
, you'll see something like this:
Load : string -> JsonProvider<"...">.Root
So, the type of the actual parsed document is a nested type Root
under the main provided type HouseValuation
. The function should then take HouseValuation.Root
as argument instead:
type HouseValuation = JsonProvider<" ... ">
let createSchoolAssignmentSearchCriteria(houseValuation:HouseValuation.Root) =
houseValuation.AddressOne
When you type HouseValuation.
you'll see the two static methods and also all the nested types there (though in this example, there is only one record type).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With