package b0

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Module B0_json.JsongSource

JSON value generation.

Generation

Sourcetype t

The type for generated JSON values.

Sourceval null : t

null is the generated JSON null value.

Sourceval bool : bool -> t

bool b is b as a generated JSON boolean value.

Sourceval int : int -> t

int i is i as a generated JSON number.

Sourceval float : float -> t

float f is f as a generated JSON number.

Sourceval string : string -> t

str s is s as a generated JSON string value.

Sourcetype array

The type for generated JSON arrays.

Sourceval array : array

array is an empty array.

Sourceval array_end : array -> t

array_end els is arr a a generated JSON value.

Sourceval el : t -> array -> array

el e arr is array arr wit e added at the end.

Sourceval el_if : bool -> (unit -> t) -> array -> array

el cond v arr is el (v ()) arr if cond is true and arr otherwise.

Sourcetype obj

The type for generated JSON objects.

Sourceval obj : obj

obj is an empty object.

Sourceval obj_end : obj -> t

obj_end o is o as a generated JSON value.

Sourceval mem : string -> t -> obj -> obj

mem name v o is o with member name bound to value v added.

Sourceval mem_if : bool -> string -> (unit -> t) -> obj -> obj

mem_if cond name v o is mem name (v ()) o if cond is true and o otherwise.

Derived generators

Sourceval strf : ('a, Format.formatter, unit, t) format4 -> 'a

strf fmt ... is a JSON string generated value formatted according to fmt.

Sourceval option : ('a -> t) -> 'a option -> t

option some o is o as a generated JSON value which is null if o is None and some v if o is some v.

Sourceval list : ('a -> t) -> 'a list -> t

list el l is l as a generated JSON array whose elements are generated using el.

Sourceval json : Json.t -> t

of_json v is the JSON value v as a generated value.

Output

Sourceval buffer_add : Buffer.t -> t -> unit

buffer_add b g adds the generated JSON value g to b.

Sourceval to_string : t -> string

to_string g is the generated JSON value g as a string.