module Build:This submodule provides some simple functions for building JSON data from other OCaml types.sig..end
Use open Json_type.Build when you want to convert JSON data
into another OCaml type.
val null : Json_type.tNull valueval bool : bool -> Json_type.tBoolval int : int -> Json_type.tIntval float : float -> Json_type.tFloatval string : string -> Json_type.tStringval objekt : (string * Json_type.t) list -> Json_type.tObject.
See Json_type.Browse.objekt for an explanation about the unusual
spelling.
val array : Json_type.t list -> Json_type.tArray.val list : ('a -> Json_type.t) -> 'a list -> Json_type.tlist f l maps OCaml list l to a JSON list using
function f to convert the elements into JSON values.
For example, list int [1; 2; 3] is a shortcut for
Array [ Int 1; Int 2; Int 3 ].
val option : Json_type.t option -> Json_type.toption x returns Null is x is None, or y if
x is Some y.val optional : ('a -> Json_type.t) -> 'a option -> Json_type.toptional f x returns Null if x is None, or f x
otherwise.
For example, list (optional int) [Some 1; Some 2; None] returns
Array [ Int 1; Int 2; Null ].