Parse numbers from strings, implement general recursion (#12)

This commit is contained in:
Patrick Stevens
2023-12-27 20:21:13 +00:00
committed by GitHub
parent 39d603c317
commit 5144ba2c17
5 changed files with 354 additions and 84 deletions

View File

@@ -24,15 +24,24 @@ namespace ConsumePlugin
module JsonRecordType =
/// Parse from a JSON node.
let jsonParse (node : System.Text.Json.Nodes.JsonNode) : JsonRecordType =
let F =
node.["f"].AsArray ()
|> Seq.map (fun elt -> elt.AsValue().GetValue<int> ())
|> Array.ofSeq
let E =
node.["e"].AsArray ()
|> Seq.map (fun elt -> elt.AsValue().GetValue<string> ())
|> Array.ofSeq
let D = InnerType.jsonParse node.["d"]
let C =
node.["hi"].AsArray ()
|> Seq.map (fun elt -> elt.GetValue<int> ())
|> Seq.map (fun elt -> elt.AsValue().GetValue<int> ())
|> List.ofSeq
let B2 = node.["another-thing"].AsValue ()
let B = B2.GetValue<string> ()
let B = node.["another-thing"].AsValue().GetValue<string> ()
let A = node.["a"].AsValue().GetValue<int> ()
{
@@ -40,4 +49,6 @@ module JsonRecordType =
B = B
C = C
D = D
E = E
F = F
}

View File

@@ -25,4 +25,6 @@ type JsonRecordType =
[<System.Text.Json.Serialization.JsonPropertyName "hi">]
C : int list
D : InnerType
E : string array
F : int[]
}