Legend:
Library
Module
Module type
Parameter
Class
Class type
JSON value queries.
TODO maybe we could expose a bit more options for error reporting. In particular the internal path type and a combinator in the vein of loc to report back the path trace. Basically see Serialk_sexp.
Queries
type'a t
The type JSON value queries. A query either fails or succeeds against a JSON value returning a value of type 'a.
val query : 'at->Json.t->('a, string)Stdlib.result
query q j is Ok v if que query q succeeds on s and a (multiline) Error e otherwise.
fail msg is a query that fails on any JSON value with message msg. Do not include position information in msg, this is automatically handled by the module.
val failf : ('a, Stdlib.Format.formatter, unit, 'bt)Stdlib.format4->'a
failf fmt ... is like fail but formats the message according to fmt.
string queries JSON string values as a string value and fails otherwise.
val string_to : kind:string ->(string ->('a, string)Stdlib.result)->'at
string_to ~kind parse queries a JSON string and parses it with p. In case of Error m error fails with m. kind is the kind of value parsed, it is used for the error in case no JSON string is found.
val enum : kind:string ->Stdlib.Set.Make(Stdlib.String).t ->string t
enum ~kind ss queries a JSON string for one of the elements of ss and fails otherwise. kind is for the kind of elements in ss, it used for error reporting.
val enum_map : kind:string ->'aStdlib.Map.Make(Stdlib.String).t->'at
enum_map ~kind sm queries a string for it's map in sm and fails if the string is not bound in sm. kind is for the kind elements in sm, it is used for error reporting.
nth ?absent n q queries the nth element of an array with q. If n is negative counts from the end of the array, so -1 is the last array element. If the element does not exist this fails if absent is None and succeeds with v if absent is Some v.