Module Odig.Private.Json

module Json: sig .. end
JSON text generation.

Warning. The module assumes strings are UTF-8 encoded.

Generation sequences

type 'a seq 
The type for sequences.
val empty : 'a seq
An empty sequence.
val (++) : 'a seq ->
'a seq -> 'a seq
s ++ s' is sequence s' concatenated to s.

JSON values

type t 
The type for JSON values.
type mem 
The type for JSON members.
type el 
The type for JSON array elements.
val null : t
null is the JSON null value.
val bool : bool -> t
bool b is b as a JSON boolean value.
val int : int -> t
int i is i as a JSON number.
val str : string -> t
str s is s as a JSON string value.
val el : t -> el seq
el v is v as a JSON array element.
val el_if : bool ->
(unit -> t) -> el seq
el_if c v is el (v ()) if c is true and Odig.Private.Json.empty otherwise.
val arr : el seq -> t
arr els is an array whose values are defined by the elements els.
val mem : string -> t -> mem seq
mem n v is an object member whose name is n and value is v.
val mem_if : bool ->
string ->
(unit -> t) -> mem seq
mem_if c n v is mem n v if c is true and Odig.Private.Json.empty otherwise.
val obj : mem seq -> t
obj mems is an object whose members are mems.


val buffer_add : Buffer.t -> t -> unit
buffer_add b j adds the JSON value j to b.
val to_string : t -> string
to_string j is the JSON value j as a string.
val output : Pervasives.out_channel -> t -> unit
output oc j outputs the JSON value j on oc.