Module Jsont.Path

JSON paths.

Paths are used for keeping track of encoding and decoding contexts and for specifying queries.


type index =
  1. | Mem of string node

    Indexes the value of the member n of an object.

  2. | Nth of int node

    Indexes the value of the nth element of an array. If negative counts the number of elements from the end: -1 is that last element.


The type for indexing operations on JSON values.

val pp_index : index fmt

pp_index formats indexes.

val pp_index_trace : index fmt

pp_index formats indexes and their location.


type t

The type for paths, a sequence of indexing operations.

val root : t

root is the root path.

val is_root : t -> bool

is_root p is true iff p is the root path.

val nth : ?meta:Meta.t -> int -> t -> t

nth n p indexes the array indexed by p at index n.

val mem : ?meta:Meta.t -> string -> t -> t

mem n p indexes the object indexed by p at member n.

val rev_indices : t -> index list

rev_indices p are the indices of p in reverse order.

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

of_string s parses a path according to the path syntax.

val pp : t fmt

pp formats paths.

val pp_trace : t fmt

pp_path_trace formats paths as a stack trace, if not empty.