tangled
alpha
login
or
join now
anil.recoil.org
/
ocaml-json-pointer
0
fork
atom
RFC6901 JSON Pointer implementation in OCaml using jsont
0
fork
atom
overview
issues
pulls
pipelines
pp-error
anil.recoil.org
2 months ago
4efc8734
e8c0b581
0/1
build.yml
failed
2min 33s
+6
-2
1 changed file
expand all
collapse all
unified
split
doc
tutorial.md
+6
-2
doc/tutorial.md
···
12
12
# open Jsont_pointer;;
13
13
# #install_printer Jsont_pointer_top.printer;;
14
14
# #install_printer Jsont_pointer_top.json_printer;;
15
15
+
# #install_printer Jsont_pointer_top.error_printer;;
15
16
# let parse_json s =
16
17
match Jsont_bytesrw.decode_string Jsont.json s with
17
18
| Ok json -> json
···
129
130
130
131
```ocaml
131
132
# of_string "foo";;
132
132
-
Exception: Jsont.Error ([], <abstr>, <abstr>).
133
133
+
Exception:
134
134
+
Jsont.Error Invalid JSON Pointer: must be empty or start with '/': foo.
133
135
```
134
136
135
137
The RFC is strict: non-empty pointers MUST start with `/`.
···
273
275
274
276
```ocaml
275
277
# get_result (of_string "/nonexistent") rfc_example;;
276
276
-
- : (Jsont.json, Jsont.Error.t) result = Error ([], <abstr>, <abstr>)
278
278
+
- : (Jsont.json, Jsont.Error.t) result =
279
279
+
Error JSON Pointer: member 'nonexistent' not found
280
280
+
File "-":
277
281
# find (of_string "/nonexistent") rfc_example;;
278
282
- : Jsont.json option = None
279
283
```