module Build:sig
..end
Use open Json_type.Build
when you want to convert JSON data
into another OCaml type.
val null : Json_type.t
Null
valueval bool : bool -> Json_type.t
Bool
val int : int -> Json_type.t
Int
val float : float -> Json_type.t
Float
val string : string -> Json_type.t
String
val objekt : (string * Json_type.t) list -> Json_type.t
Object
.
See Json_type.Browse.objekt
for an explanation about the unusual
spelling.
val array : Json_type.t list -> Json_type.t
Array
.val list : ('a -> Json_type.t) -> 'a list -> Json_type.t
list 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.t
option x
returns Null
is x
is None
, or y
if
x
is Some y
.val optional : ('a -> Json_type.t) -> 'a option -> Json_type.t
optional 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 ]
.