package wcs-lib

  1. Overview
  2. Docs

Json with embedded expressions utilities.

Builders

The null value of JSON.

val int : int -> Json_spel_t.json_spel

int n build the value of JSON n.

val bool : bool -> Json_spel_t.json_spel

bool b build the value of JSON b.

val string : string -> Json_spel_t.json_spel

string s build the value of JSON s.

val assoc : (string * Json_spel_t.json_spel) list -> Json_spel_t.json_spel

assoc o build the JSON object o.

list l build the JSON list l.

json/json_spel conversion

to_json v convert v value into json. Expressions are turned into strings with using the Spel concrete syntax.

of_json j convert j into json_spel. Strings literals in j are parsed as text containing quoted spel expressions.

Manipulation functions

set o x v add (or replace) the a field x of the object o with value v.

val get : Json_spel_t.json_spel -> string -> Json_spel_t.json_spel option

get o x gets the value of the field x of the object o.

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.

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).

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.

pop o x take a value in a list stored in the field x of o.

Settes and getters
Boolean fields
val set_bool : Json_spel_t.json_spel -> string -> bool -> Json_spel_t.json_spel

set_bool o x b sets the a field x of the object o with value b.

val get_bool : Json_spel_t.json_spel -> string -> bool option

get_bool o x gets the value of the field x of the object o.

String fields
val set_string : Json_spel_t.json_spel -> string -> string -> Json_spel_t.json_spel

set_string o x x sets the a field x of the object o with string s.