Module Openai_gym.Json

val read_json_file : (Yojson.lexer_state -> Stdlib.Lexing.lexbuf -> 'a) -> string -> 'a

read_json_file reader fname reads the file fname using the reader reader generated by atdgen.

Builders

val null : Json_t.json

The null value of JSON.

val int : int -> Json_t.json

int n build the value of JSON n.

val bool : bool -> Json_t.json

bool b build the value of JSON b.

val string : string -> Json_t.json

string s build the value of JSON s.

val assoc : (string * Json_t.json) list -> Json_t.json

assoc o build the JSON object o.

val list : Json_t.json list -> Json_t.json

list l build the JSON list l.

Manipulation functions

val set : Json_t.json -> string -> Json_t.json -> Json_t.json

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

val get : Json_t.json -> string -> Json_t.json option

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

val take : Json_t.json -> string -> Json_t.json * Json_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 : Json_t.json list -> Json_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 : Json_t.json -> string -> Json_t.json -> Json_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 : Json_t.json -> string -> Json_t.json * Json_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 : Json_t.json -> string -> bool -> Json_t.json

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

val get_bool : Json_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 : Json_t.json -> string -> string -> Json_t.json

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

val get_string : Json_t.json -> string -> string option

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

val take_string : Json_t.json -> string -> Json_t.json * string option

take_string o x takes the value of the field x of the object o.