Crdt.Pointer

crdt · API reference

JSON Pointer (RFC 6901) for path-based access

JSON Pointer (RFC 6901) implementation.

JSON Pointer defines a string syntax for identifying a specific value within a JSON document. Example: "/foo/0/bar"

type t = string list

A JSON Pointer is a list of reference tokens

val empty : t

empty is the root pointer

val of_string : string -> (t, string) result

of_string s parses a JSON Pointer string. Returns Error if the string is invalid.

val to_string : t -> string

to_string p converts a pointer to its string representation

val append : t -> string -> t

append p token adds a token to the pointer

val parent : t -> t option

parent p returns the parent pointer, or None if already root

val last : t -> string option

last p returns the last token, or None if root pointer

val length : t -> int

length p returns the number of tokens

val is_root : t -> bool

is_root p returns true if this is the root pointer

val concat : t -> t -> t

concat p1 p2 concatenates two pointers

val resolve : t -> Value.t -> Value.t option

resolve p v resolves a pointer against a Value.t, returning the value at that path

val pp : Format.formatter -> t -> unit

pp fmt p pretty-prints a pointer

val equal : t -> t -> bool

equal p1 p2 returns true if pointers are equal

val compare : t -> t -> int

compare p1 p2 compares two pointers

val parse : string -> t

parse s parses a JSON Pointer string. Raises Invalid_argument if invalid.

val segments : t -> string list

segments p returns the list of path segments