JSON parsing Using F # (not serialization)

I am trying to create a tree (through a discriminated union type) in my F # application to represent my data in a general way. I researched what is available on the Internet and I found things like JavaScriptSerializer and DataContractJsonSerializer . The problem is that I really do not serialize the data to a specific object.

Here is my discriminatory union:

type ParameterTree =
    | End
    | Node of string * Dictionary<string, Parameter> * ParameterTree

Basically, I want to be able to read from the stream and populate the ParameterTree with the data that I get from the stream (including the appropriate parent / child relationship). I'm stuck on where to start. If someone can point me in the right direction, I would appreciate it.

+3
source share
1

, , .NET-, F #.

Json.NET JObject.Parse, , , . # -:

JObject o = JObject.Parse(json);
string name = (string)o["Name"];
JArray sizes = (JArray)o["Sizes"];
string smallest = (string)sizes[0];

JObject JArray .

+3

All Articles