Sanchime.Json/Program.fs

29 lines
623 B
Forth
Raw Permalink Normal View History

2022-06-26 09:36:21 +08:00
open Sanchime.Json
open Sanchime.Json.Parser
2022-06-25 16:49:05 +08:00
let json = """
{
"Name": "Bob",
"Email": "bob@example.com",
"IsActive": true,
"Info": {
"Age": 18,
"Gender": "男",
"Address": "江西",
"City": "赣州",
"Record": [
"小学",
"初中",
"高中"
]
}
}
"""
2022-06-26 09:36:21 +08:00
let foo = function
| Object v -> v
| _ -> failwith "其他"
2022-06-25 16:49:05 +08:00
let user = json |> parse
2022-06-26 09:36:21 +08:00
user |> foo |> List.iter (fun a -> printfn $"Name: {fst a}, Value: {snd a}")