Library
Module
Module type
Parameter
Class
Class type
The Json
module provides helpers to manipulate JSON objects.
val create :
?kind:[ `Str of string | `Float of float | `Obj | `Arr ] ->
unit ->
t
create ~kind ()
generates a new t
object. Default kind value is `Obj
.
val error : string -> t
error msg
produces a type t
from an error message.
val of_string : string -> t
of_string str
takes a string str
representing a JSON and transform it into an t
object you can manipulate with this module.
geta json nth
. returns the t
value associated to the nth element in the json.
getao json (k,v)
returns the t
value object associated with the first element in an array of object which contains the tuple (k,v).
to_int_r json
transforms the json
object into an int result with a printable error in case of failure.
to_float_r json
transforms the json
object into an float result with a printable error in case of failure.
to_string json
transforms the json
into a string result with a printable error in case of failure.
to_unit_r json
returns a result with a unit value. It unwraps the errors and returns unit if there is no error.
pp_r json
prints the json if it's a well format json and returns Ok (). Otherwise, it returns an error.
export json
returns a string that represents the json.
module Private : sig ... end
/!\ Private area should not be used while using the API!