Module Kojson

module Kojson: sig .. end
Pattern Domains and Supporting Definitions.


Prerequisites


type json = [ `Assoc of (string * json) list
| `Bool of bool
| `Float of float
| `Int of int
| `List of json list
| `Null
| `String of string ]
The JSON tree, compatible with Yojson.Basic.json.
type path = [ `Index of int | `Label of string ] list 
A path of crossed association labels and array indices, used to locate a pattern mismatch for better error reporting.
val string_of_path : path -> string
Convert a label and index path to a human readable string.
type expectation = [ `either of (path * expectation) list
| `expecting_label of string
| `expecting_type of string
| `expecting_value of json
| `expecting_values of json list
| `not_expecting_labels of string list ]
Details of what was expected at the location where a pattern didn't match.
exception Mismatch of path * expectation
Exception raised to indicate a mismatch of a JSON value. The first parameter is a path leading up to the error, and the second parameter explains the expected value.
val string_of_mismatch : path * expectation -> string
Format a explanation of why a pattern did not match.
val default_warn : (path -> string -> unit) Pervasives.ref
This is the default warning handler used by Kojson.jin_of_json.

Pattern Domains

The following types form the domain of patterns, which can be built up from the definitions in Kojson_pattern.

type jin = Kojson_private.jin 
A JSON value paired with a path and a custom warning callback to facilitate error reporting. A pattern is a function of type jin -> 'a which throws Kojson.Mismatch if it does not match its argument.
val jin_of_json : ?warn:(path -> string -> unit) ->
?path:path -> json -> jin
Pair a JSON value with a path for use during matching.
warn : A callback to record warnings about unused labels. The default is Kojson.default_warn.
path : The root path of JSON tree, if not [].
val jin_path : jin -> path
type jain = Kojson_private.jain 
A wrapper for an opened JSON association paired with a path and a custom warning callback to facility error reporting. An association pattern is a function of type jain -> 'a which throws Kojson.Mismatch if it does not match its argument.
val jain_path : jain -> path