Module Json.Cons

JSON value constructors.

type json := t
type 'a t = ?meta:Meta.t -> 'a -> json

The type for constructing JSON values from an OCaml value of type 'a. meta defaults to Meta.none.

Base types

val null : unit t

null is Null (unit, meta).

val bool : bool t

bool b is Bool (b, meta).

val number : float t

number n is Number (n, meta).

val string : string t

string s is String (s, meta).

val array : json array t

array l is Array (Array.to_list a, meta). See also list.

Objects

val name : ?meta:Meta.t -> string -> name

name ?meta n is (n, meta). meta defaults to Meta.none.

val mem : name -> json -> mem

mem n v is (n, v). meta defaults to Meta.none.

val obj : obj t

obj o is Obj (o, meta).

Derived

val option : 'a t -> 'a option t

option c constructs Some v values with c v and None ones with null.

val list : json list t

list l is Array (l, meta).

val int : int t

int is i as a JSON number or a JSON string if not in the range [-253;253]. See also int_as_string.

val int32 : int32 t

int32 is i as a JSON number.

val int64 : int64 t

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_as_string : int t

int_as_string i is i as a JSON string. See also int.

val int64_as_string : int64 t

int64_as_string i is i as a JSON string. See also int64.

val any_float : float t

any_float v is number v if Float.is_finite v is true and string (Float.to_string v) otherwise. See Jsont.any_float.