package wcs-lib
Json utilities.
val read_json_file :
(Yojson.lexer_state -> Lexing.lexbuf -> 'a) ->
string ->
'a
read_json_file reader fname
reads the file fname
using the reader reader
generated by atdgen.
Builders
val null : Wcs_t.json
The null
value of JSON.
val int : int -> Wcs_t.json
int n
build the value of JSON n
.
val bool : bool -> Wcs_t.json
bool b
build the value of JSON b
.
val string : string -> Wcs_t.json
string s
build the value of JSON s
.
val assoc : (string * Wcs_t.json) list -> Wcs_t.json
assoc o
build the JSON object o
.
val list : Wcs_t.json list -> Wcs_t.json
list l
build the JSON list l
.
Manipulation functions
val set : Wcs_t.json -> string -> Wcs_t.json -> Wcs_t.json
set o x v
add (or replace) the a field x
of the object o
with value v
.
val get : Wcs_t.json -> string -> Wcs_t.json option
get o x
gets the value of the field x
of the object o
.
val take : Wcs_t.json -> string -> Wcs_t.json * Wcs_t.json option
take o x
gets the value of the field x
of the object o
and remove the field from the object. The left part of the return value is the modified object and the right part is the value of the field.
val assign : Wcs_t.json list -> Wcs_t.json
assign [o1; ...; on]
create a json object that contains all the fields of the objets o1
, ..., on
. It is similare the the JavaScript function Object.assing({}, o1, ... on)
.
val push : Wcs_t.json -> string -> Wcs_t.json -> Wcs_t.json
push o x v
add the value v
in the list stored in a field x
of the object o
. It the field x
doesn't exists, it creates it.
val pop : Wcs_t.json -> string -> Wcs_t.json * Wcs_t.json option
pop o x
take a value in a list stored in the field x
of o
.
Setters and getters
Boolean fields
val set_bool : Wcs_t.json -> string -> bool -> Wcs_t.json
set_bool o x b
sets the a field x
of the object o
with value b
.
val get_bool : Wcs_t.json -> string -> bool option
get_bool o x
gets the value of the field x
of the object o
.
String fields
val set_string : Wcs_t.json -> string -> string -> Wcs_t.json
set_string o x x
sets the a field x
of the object o
with string s
.
val get_string : Wcs_t.json -> string -> string option
get_string o x
gets the value of the field x
of the object o
.
val take_string : Wcs_t.json -> string -> Wcs_t.json * string option
take_string o x
takes the value of the field x
of the object o
.