Module Mavryk_openapi.Json

Helpers to read JSON values.

Contains functions to parse JSON values, show them for debugging, and extract information from them.

Functions which extract information are rather strict: they don't try to be smart and automatically convert. For instance, as_record makes sure that all fields are taken into account. This is suited to write a tool that must be updated when the format of JSON values being manipulated changes. In our case, if the JSON schemas we read start to get more fields, we want to know; otherwise the resulting OpenAPI specification could be inaccurate.

include module type of struct include JSON end
type error = JSON.error
val show_error : error -> string
exception Error of error
type u = Ezjsonm.value
type t = JSON.t
val error : t -> ('a, unit, string, 'b) Stdlib.format4 -> 'a
val annotate : origin:string -> u -> t
val unannotate : t -> u
val encode : t -> string
val encode_u : u -> string
val encode_to_file : string -> t -> unit
val encode_to_file_u : string -> u -> unit
val parse_file : string -> t
val parse : origin:string -> string -> t
val parse_opt : origin:string -> string -> t option
val get : string -> t -> t
val (|->) : t -> string -> t
val geti : int -> t -> t
val (|=>) : t -> int -> t
val put : (string * t) -> t -> t
val update : string -> (t -> t) -> t -> t
val filter_map_object : t -> (string -> t -> t option) -> t
val filter_object : t -> (string -> t -> bool) -> t
val merge_objects : t -> t -> t
val is_null : t -> bool
val as_opt : t -> t option
val as_bool : t -> bool
val as_bool_opt : t -> bool option
val is_bool : t -> bool
val as_int : t -> int
val as_int_opt : t -> int option
val is_int : t -> bool
val as_int64 : t -> int64
val as_int64_opt : t -> int64 option
val is_int64 : t -> bool
val as_int32 : t -> int32
val as_int32_opt : t -> int32 option
val is_int32 : t -> bool
val as_float : t -> float
val as_float_opt : t -> float option
val is_float : t -> bool
val as_string : t -> string
val as_string_opt : t -> string option
val is_string : t -> bool
val as_list : t -> t list
val as_list_opt : t -> t list option
val is_list : t -> bool
val as_object : t -> (string * t) list
val as_object_opt : t -> (string * t) list option
val is_object : t -> bool
val equal_u : u -> u -> bool
val equal : t -> t -> bool
val as_variant : t -> string * t
val as_variant_named : t -> string -> t
val (|~>) : t -> string -> t
val as_record : t -> ((string -> t option) -> 'a) -> 'b
val output : Ezjsonm.value -> unit