3 let j = {|not valid json
|} |> Ezjsonm.from_string_result
in
5 | Error
(`Error
(((1,1),(1,3)),`Illegal_literal l
)) ->
6 l
|> Assrt.equals_string __LOC__
"not"
7 | _
-> failwith __LOC__
);
11 |> Ezjsonm.read_error_description
12 |> Assrt.equals_string __LOC__
{|illegal literal
(not
)|}
13 | _
-> failwith __LOC__
);
16 let test_constructing () =
19 ("id", `String
"398eb027");
20 ("name", `String
"John Doe");
24 ("id", Ezjsonm.int 1); ("title", `String
"The Art of Flipping Coins");
27 |> Ezjsonm.to_string ~minify
:true
28 |> Assrt.equals_string __LOC__
29 "{\"id\":\"398eb027\",\"name\":\"John \
30 Doe\",\"pages\":{\"id\":1,\"title\":\"The Art of Flipping Coins\"}}"
32 let test_load_peertube () =
33 let extract3tries k0 k1
j =
34 match Ezjsonm.find
j [ k0
] with
36 | `A
(`String s
:: _
) -> Some s
37 | `A
((`O _
as hd
) :: _
) -> (
39 match Ezjsonm.find hd
[ k1
] with `String s
-> Some s
| _
-> None
)
42 let ic = open_in
"data/peertube-video.json" in
43 ic |> Ezjsonm.from_channel
44 |> extract3tries "attributedTo" "id"
45 |> Option.get
|> Uri.of_string
|> Uri.to_string
46 |> Assrt.equals_string __LOC__
47 "https://tube.network.europa.eu/accounts/edps";
49 let ic = open_in
"data/ap/actor/peertube.0.json" in
50 let _a = Ezjsonm.from_channel
ic in
55 Unix.chdir
"../../../test/";
58 test_load_peertube ();