Library
Module
Module type
Parameter
Class
Class type
Generic JSON values.
type 'a jsont := 'a t
The type for constructing JSON values from an OCaml value of type 'a
. meta
defaults to Meta.none
.
type t = json
See Jsont.json
.
copy_layout src ~dst
copies the layout of src
and sets it on dst
using Meta.copy_ws
.
zero j
is a stub value of the sort value of j
. The stub value is the “natural” zero: null, false, 0, empty string, empty array, empty object.
compare j0 j1
is a total order on JSON values:
Float.compare
, this means NaN values are equal.Meta.t
values are ignored.See Jsont.pp_json
.
val null : unit cons
null
is Null (unit, meta)
.
option c
constructs Some v
values with c v
and None
ones with null
.
val bool : bool cons
bool b
is Bool (b, meta)
.
val number : float cons
number n
is Number (n, meta)
.
val any_float : float cons
any_float v
is number v
if Float.is_finite
v
is true
and string (Float.to_string v)
otherwise. See Jsont.any_float
.
val int32 : int32 cons
int32
is i
as a JSON number.
val int64 : int64 cons
int64 i
is i
as a JSON number or a JSON string if not in the range [-253;253]. See also int64_as_string
.
val int : int cons
int
is i
as a JSON number or a JSON string if not in the range [-253;253]. See also int_as_string
.
val string : string cons
string s
is String (s, meta)
.
find_mem n ms
find the first member whose name matches n
in ms
.
val object_names : object' -> string list
object_names ms
are the names of ms
.
decode t j
decodes a value from the generic JSON j
according to type t
.
decode'
is like decode
but preserves the error structure.
encode t v
encodes a generic JSON value for v
according to type t
.
encode'
is like encode
but preserves the error structure.
recode t v
decodes v
with t
and encodes it with t
.
recode'
is like recode
but preserves the error structure.
update
is like recode
but raises Jsont.Error
.
error_sort ~exp fnd
errors when sort exp
was expected but generic JSON fnd
was found.