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.
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.
string queries JSON string values as a string value and fails otherwise.
val string_to : kind:string ->(string ->('a, string)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.
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.
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.