I found this F# JSON parsing - How to get property using complex path (consisting of several propery names) (I shortened the file string). I am wondering how to show the actual data from the json file in the FSI window?
let soilTest = JsonValue.Load("c:\\,,,soiltest.json")
let query soilTest=
let node = JObject.Parse soilTest
node.SelectToken "person.name" |> string
"name": "John Doe",
"date": "December 1, 2015",
warning FS0020: This expression should have type 'unit', but has type 'string'. Use 'ignore' to discard the result of the expression, or 'let' to bind the result to a name.
val query : soilTest:string -> unit
soilTest is a of type
JsonValue but you're trying to parse it as
string, hence the error. Please adjust the path for your environment, otherwise this works for me:
let soilTest = JsonValue.Load(@"c:\tmp\test.json") let qry (soilTest:JsonValue) = let data = JObject.Parse (soilTest.ToString()) data.SelectToken "person.name" |> string qry soilTest //val it : string = "John Doe"
There might be better ways to work with. Json and xml are the bane of my existence...