this repo has no description
at main 1.6 kB view raw
1(** Toplevel printers for JMAP types. 2 3 Printers are automatically installed when the library is loaded: 4 {[ 5 #require "jmap.top";; 6 ]} 7 8 After loading, JMAP types will display nicely: 9 {[ 10 # Jmap.Id.of_string_exn "abc123";; 11 - : Jmap.Id.t = <id:abc123> 12 13 # Jmap.Keyword.of_string "$seen";; 14 - : Jmap.Keyword.t = `Seen 15 16 # Jmap.Role.of_string "inbox";; 17 - : Jmap.Role.t = `Inbox 18 ]} 19 20 JSON values display as formatted strings, making it easy to see 21 how OCaml types map to JMAP JSON. *) 22 23(** {1 JSON Printers} *) 24 25val json_printer : Format.formatter -> Jsont.json -> unit 26(** Formats a JSON value as a compact JSON string. *) 27 28val jsont_error_printer : Format.formatter -> Jsont.Error.t -> unit 29(** Formats a Jsont parsing error. *) 30 31(** {1 JSON Encoding Helpers} 32 33 These functions encode OCaml types to JSON, useful for understanding 34 how the library maps to JMAP wire format. *) 35 36val encode : 'a Jsont.t -> 'a -> Jsont.json 37(** [encode codec value] encodes a value to JSON using the given codec. 38 Raises [Invalid_argument] on encoding failure. *) 39 40val encode_string : 'a Jsont.t -> 'a -> string 41(** [encode_string codec value] encodes a value to a JSON string. *) 42 43val pp_as_json : 'a Jsont.t -> Format.formatter -> 'a -> unit 44(** [pp_as_json codec ppf value] pretty-prints a value as JSON. *) 45 46(** {1 Installation} *) 47 48val install : unit -> unit 49(** [install ()] installs all printers. This is called automatically when 50 the library is loaded, but can be called again if needed. *)