package jsont
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha512=6206f73a66cb170b560a72e58f70b9fb2c20397b9ab819dceba49b6602b9b79e47ba307e6910e61ca4694555c66fdcd7a17490afb99548e8f43845a5a88913e7
doc/jsont/Jsont/Json/index.html
Module Jsont.JsonSource
Generic JSON values.
JSON values
The type for constructing JSON values from an OCaml value of type 'a. meta defaults to Meta.none.
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:
- Floating point values are compared with
Float.compare, this means NaN values are equal. - Strings are compared byte wise.
- Objects members are sorted before being compared.
Meta.tvalues are ignored.
See Jsont.pp_json.
Nulls and options
option c constructs Some v values with c v and None ones with null.
Booleans
Numbers
any_float v is number v if Float.is_finite v is true and string (Float.to_string v) otherwise. See Jsont.any_float.
int64 i is i as a JSON number or a JSON string if not in the range [-253;253]. See also int64_as_string.
int is i as a JSON number or a JSON string if not in the range [-253;253]. See also int_as_string.
Strings
Arrays
Objects
name ?meta n is (n, meta). meta defaults to Meta.none.
find_mem n ms find the first member whose name matches n in ms.
Decode
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
encode t v encodes a generic JSON value for v according to type t.
encode' is like encode but preserves the error structure.
Recode
recode t v decodes v with t and encodes it with t.
recode' is like recode but preserves the error structure.
Errors
error_sort ~exp fnd errors when sort exp was expected but generic JSON fnd was found.