module Json:sig
..end
Remarks:
Number
can be used to encode non OCaml-primitive numbers,
for instance Zarith.typejson =
[ `Assoc of (string * json) list
| `Bool of bool
| `Float of float
| `Int of int
| `List of json list
| `Null
| `String of string ]
Same type than Yojson.Basic.json
typet =
json
val equal : t -> t -> bool
val compare : t -> t -> int
val pp : Format.formatter -> t -> unit
val pp_dump : Format.formatter -> t -> unit
exception Error of Filepath.Normalized.t * int * string
val of_bool : bool -> t
val of_int : int -> t
val of_string : string -> t
val of_float : float -> t
val of_list : t list -> t
val of_array : t array -> t
val of_fields : (string * t) list -> t
Error
in case of error.val load_lexbuf : Lexing.lexbuf -> t
val load_channel : ?file:string -> Pervasives.in_channel -> t
val load_string : string -> t
val load_file : string -> t
~pretty:false
.val save_string : ?pretty:bool -> t -> string
val save_buffer : ?pretty:bool -> Buffer.t -> t -> unit
val save_channel : ?pretty:bool -> Pervasives.out_channel -> t -> unit
val save_formatter : ?pretty:bool -> Format.formatter -> t -> unit
val save_file : ?pretty:bool -> string -> t -> unit
Invalid_argument
in case of wrong
format.val bool : t -> bool
True
and False
only.Invalid_argument
when the conversion fails.val int : t -> int
Null
, Int
, Float
, Number
and String
to an int
.
Floats are truncated with int_of_float
and Null
to 0.Invalid_argument
when the conversion fails.val string : t -> string
Null
, Int
, Float
, Number
and String
to a string
.
Floats are truncated with string_of_float
and Null
to ""
.Invalid_argument
when the conversion fails.val float : t -> float
Null
, Int
, Float
, Number
and String
to float
and Null
to 0.0
.Invalid_argument
when the conversion fails.val array : t -> t array
Array
object.
Null
is considered an empty array.Invalid_argument
if the object is not an array.val list : t -> t list
Array
object.
Null
is considered an empty list.Invalid_argument
if the object is not a list.val assoc : t -> (string * t) list
Assoc
object.
Null
is considered an empty assoc.Invalid_argument
if the object is not a list.val fold : (string -> t -> 'a -> 'a) -> t -> 'a -> 'a
Null
is considered an empty object.
Typical usage is fold M.add t M.empty
where M=Map.Make(String)
.Invalid_argument
if the object is not an Assoc
or Null
object.val field : string -> t -> t
Null
is considered an empty object.Not_found
if the field is absent from the object.Invalid_argument
if the object is not an Assoc
or Null
object.