Module Openai_gym.Json
val read_json_file : (Yojson.lexer_state -> Stdlib.Lexing.lexbuf -> 'a) -> string -> 'a
read_json_file reader fname
reads the filefname
using the readerreader
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 JSONn
.
val bool : bool -> Json_t.json
bool b
build the value of JSONb
.
val string : string -> Json_t.json
string s
build the value of JSONs
.
val assoc : (string * Json_t.json) list -> Json_t.json
assoc o
build the JSON objecto
.
val list : Json_t.json list -> Json_t.json
list l
build the JSON listl
.
Manipulation functions
val set : Json_t.json -> string -> Json_t.json -> Json_t.json
set o x v
add (or replace) the a fieldx
of the objecto
with valuev
.
val get : Json_t.json -> string -> Json_t.json option
get o x
gets the value of the fieldx
of the objecto
.
val take : Json_t.json -> string -> Json_t.json * Json_t.json option
take o x
gets the value of the fieldx
of the objecto
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 objetso1
, ...,on
. It is similare the the JavaScript functionObject.assing({}, o1, ... on)
.
val push : Json_t.json -> string -> Json_t.json -> Json_t.json
push o x v
add the valuev
in the list stored in a fieldx
of the objecto
. It the fieldx
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 fieldx
ofo
.
Setters and getters
Boolean fields
val set_bool : Json_t.json -> string -> bool -> Json_t.json
set_bool o x b
sets the a fieldx
of the objecto
with valueb
.
val get_bool : Json_t.json -> string -> bool option
get_bool o x
gets the value of the fieldx
of the objecto
.
String fields
val set_string : Json_t.json -> string -> string -> Json_t.json
set_string o x x
sets the a fieldx
of the objecto
with strings
.
val get_string : Json_t.json -> string -> string option
get_string o x
gets the value of the fieldx
of the objecto
.
val take_string : Json_t.json -> string -> Json_t.json * string option
take_string o x
takes the value of the fieldx
of the objecto
.