···7777 (** [unescape s] unescapes a JSON Pointer reference token.
7878 Specifically, [~1] becomes [/] and [~0] becomes [~].
79798080- @raise Jsont.Error.Error if [s] contains invalid escape sequences
8080+ @raise Jsont.exception-Error if [s] contains invalid escape sequences
8181 (a [~] not followed by [0] or [1]). *)
8282end
8383···202202203203val to_nav_exn : any -> nav t
204204(** [to_nav_exn p] returns the navigation pointer if [p] is one.
205205- @raise Jsont.Error.Error if [p] is an append pointer. *)
205205+ @raise Jsont.exception-Error if [p] is an append pointer. *)
206206207207(** {2:parsing Parsing} *)
208208···217217 with [/]. Each segment between [/] characters is unescaped as a
218218 reference token.
219219220220- @raise Jsont.Error.Error if [s] has invalid syntax:
220220+ @raise Jsont.exception-Error if [s] has invalid syntax:
221221 - Non-empty string not starting with [/]
222222 - Invalid escape sequence ([~] not followed by [0] or [1])
223223 - [-] appears in non-final position *)
···230230 differently, or when you need a typed pointer for operations that
231231 require a specific kind.
232232233233- @raise Jsont.Error.Error if [s] has invalid syntax. *)
233233+ @raise Jsont.exception-Error if [s] has invalid syntax. *)
234234235235val of_string_nav : string -> nav t
236236(** [of_string_nav s] parses a JSON Pointer that must not contain [-].
···238238 Use this when you need a {!nav} pointer for retrieval operations
239239 like {!get} or {!find}.
240240241241- @raise Jsont.Error.Error if [s] has invalid syntax or contains [-]. *)
241241+ @raise Jsont.exception-Error if [s] has invalid syntax or contains [-]. *)
242242243243val of_string_result : string -> (any, string) result
244244(** [of_string_result s] is like {!of_string} but returns a result
···251251 according to {{:https://www.rfc-editor.org/rfc/rfc3986}RFC 3986}.
252252 The leading [#] should {b not} be included in [s].
253253254254- @raise Jsont.Error.Error on invalid syntax or invalid percent-encoding. *)
254254+ @raise Jsont.exception-Error on invalid syntax or invalid percent-encoding. *)
255255256256val of_uri_fragment_nav : string -> nav t
257257(** [of_uri_fragment_nav s] is like {!of_uri_fragment} but requires
258258 the pointer to not contain [-].
259259260260- @raise Jsont.Error.Error if invalid or contains [-]. *)
260260+ @raise Jsont.exception-Error if invalid or contains [-]. *)
261261262262val of_uri_fragment_result : string -> (any, string) result
263263(** [of_uri_fragment_result s] is like {!of_uri_fragment} but returns
···317317val get : nav t -> Jsont.json -> Jsont.json
318318(** [get p json] retrieves the value at pointer [p] in [json].
319319320320- @raise Jsont.Error.Error if:
320320+ @raise Jsont.exception-Error if:
321321 - The pointer references a nonexistent object member
322322 - The pointer references an out-of-bounds array index
323323 - An index type doesn't match the JSON value (e.g., [Nth]
···353353 This accepts {!type:any} pointers directly from {!of_string}:
354354 {[set (of_string "/tasks/-") json ~value:(Jsont.Json.string "new task")]}
355355356356- @raise Jsont.Error.Error if the pointer doesn't resolve to an existing
356356+ @raise Jsont.exception-Error if the pointer doesn't resolve to an existing
357357 location (except for {!append} pointers on arrays). *)
358358359359val add : any -> Jsont.json -> value:Jsont.json -> Jsont.json
···368368 valid (0 to length inclusive).}
369369 {- For {!append} pointers: Appends [value] to the array.}}
370370371371- @raise Jsont.Error.Error if:
371371+ @raise Jsont.exception-Error if:
372372 - The parent of the target location doesn't exist
373373 - An array index is out of bounds (except for {!append} pointers)
374374 - The parent is not an object or array *)
···379379 For objects, removes the member. For arrays, removes the element
380380 and shifts subsequent elements.
381381382382- @raise Jsont.Error.Error if:
382382+ @raise Jsont.exception-Error if:
383383 - [p] is the root (cannot remove the root)
384384 - The pointer doesn't resolve to an existing value *)
385385···388388389389 Unlike {!add}, this requires the target to exist.
390390391391- @raise Jsont.Error.Error if the pointer doesn't resolve to an existing value. *)
391391+ @raise Jsont.exception-Error if the pointer doesn't resolve to an existing value. *)
392392393393val move : from:nav t -> path:any -> Jsont.json -> Jsont.json
394394(** [move ~from ~path json] moves the value from [from] to [path].
···396396 This is equivalent to {!remove} at [from] followed by {!add}
397397 at [path] with the removed value.
398398399399- @raise Jsont.Error.Error if:
399399+ @raise Jsont.exception-Error if:
400400 - [from] doesn't resolve to a value
401401 - [path] is a proper prefix of [from] (would create a cycle) *)
402402···406406 This is equivalent to {!get} at [from] followed by {!add}
407407 at [path] with the retrieved value.
408408409409- @raise Jsont.Error.Error if [from] doesn't resolve to a value. *)
409409+ @raise Jsont.exception-Error if [from] doesn't resolve to a value. *)
410410411411val test : nav t -> Jsont.json -> expected:Jsont.json -> bool
412412(** [test p json ~expected] tests if the value at [p] equals [expected].
···511511 The syntax is the same as RFC 6901 JSON Pointer, except [*] is allowed
512512 as a reference token for array mapping.
513513514514- @raise Jsont.Error.Error if [s] has invalid syntax. *)
514514+ @raise Jsont.exception-Error if [s] has invalid syntax. *)
515515516516 val of_string_result : string -> (t, string) result
517517 (** [of_string_result s] is like {!of_string} but returns a result. *)
···528528 For [*] tokens on arrays, maps through all elements and collects results.
529529 Results that are arrays are flattened into the output.
530530531531- @raise Jsont.Error.Error if:
531531+ @raise Jsont.exception-Error if:
532532 - A standard token doesn't resolve (member not found, index out of bounds)
533533 - [*] is used on a non-array value
534534 - [-] appears in the pointer (not supported in JMAP extended pointers) *)
···561561 (Jsont.list Jsont.string)
562562 ]}
563563564564- @raise Jsont.Error.Error if the pointer fails to resolve (and no [absent])
564564+ @raise Jsont.exception-Error if the pointer fails to resolve (and no [absent])
565565 or if decoding with [codec] fails. *)
566566567567 val path_list : t -> 'a Jsont.t -> 'a list Jsont.t
···576576 Jmap.path (Jmap.of_string "/list/*/id") (Jsont.list Jsont.string)
577577 ]}
578578579579- @raise Jsont.Error.Error if pointer resolution fails, the result is not an array,
579579+ @raise Jsont.exception-Error if pointer resolution fails, the result is not an array,
580580 or any element fails to decode. *)
581581end