RFC6901 JSON Pointer implementation in OCaml using jsont
1(** Toplevel printers for {!Json_pointer}, {!type:Jsont.json}, and {!Jsont.Error.t}.
2
3 Printers are automatically installed when the library is loaded:
4 {[
5 #require "json-pointer.top";;
6 ]}
7
8 After loading, JSON Pointers will display their structure:
9 {[
10 # Json_pointer.of_string_nav "/foo/0";;
11 - : Json_pointer.nav Json_pointer.t = [Mem "foo"; Nth 0]
12 ]}
13
14 JSON values will display as formatted JSON strings:
15 {v
16 # Jsont_bytesrw.decode_string Jsont.json {|{"foo": [1, 2]}|};;
17 - : Jsont.json = {"foo": [1, 2]}
18 v}
19
20 And errors will display as readable messages:
21 {[
22 # Json_pointer.of_string "invalid";;
23 Exception: Jsont.Error: Invalid JSON Pointer: must be empty or start with '/'
24 ]} *)
25
26val nav_printer : Format.formatter -> Json_pointer.nav Json_pointer.t -> unit
27(** [nav_printer] formats a navigation JSON Pointer showing its index structure.
28 Suitable for use with [#install_printer]. *)
29
30val append_printer : Format.formatter -> Json_pointer.append Json_pointer.t -> unit
31(** [append_printer] formats an append JSON Pointer showing its index structure.
32 Suitable for use with [#install_printer]. *)
33
34val json_printer : Format.formatter -> Jsont.json -> unit
35(** [json_printer] formats a {!type:Jsont.json} value as a human-readable
36 JSON string. Suitable for use with [#install_printer]. *)
37
38val error_printer : Format.formatter -> Jsont.Error.t -> unit
39(** [error_printer] formats a {!Jsont.Error.t} as a human-readable
40 error message. Suitable for use with [#install_printer]. *)
41
42val install : unit -> unit
43(** [install ()] installs all printers. This is called automatically when
44 the library is loaded, but can be called again if needed (e.g., in
45 test environments where automatic initialization doesn't run). *)