Module Json

module Json: sig .. end
Json Library

Remarks:



type t = 
| Null
| True
| False
| String of string
| Number of string
| Int of int
| Float of float
| Array of t list
| Assoc of (string * t) list
Json Objects
val equal : t -> t -> bool
Pervasives
val compare : t -> t -> int
Pervasives
val pp : Format.formatter -> t -> unit
exception Error of string * int * string
file, line, message

Parsers

Parsing raise Error in case of error.
val of_lexbuf : Lexing.lexbuf -> t
val of_channel : Pervasives.in_channel -> t
val of_string : string -> t
val of_file : string -> t
May also raise system exception.

Printers

Printers use formatting unless ~pretty:false.
val to_string : ?pretty:bool -> t -> string
val to_buffer : ?pretty:bool -> Buffer.t -> t -> unit
val to_channel : ?pretty:bool -> Pervasives.out_channel -> t -> unit
val to_file : ?pretty:bool -> string -> t -> unit

Accessors

Accessors raise exception Invalid_argument in case of wrong format.
val bool : t -> bool
Extract True and False only.
Raises Invalid_argument when the conversion fails.
val int : t -> int
Convert Int, Float, Number and String to an int. Floats are truncated with int_of_float.
Raises Invalid_argument when the conversion fails.
val float : t -> float
Convert Int, Float, Number and String to float.
Raises Invalid_argument when the conversion fails.
val array : t -> t array
Extract the array of an Array object. Null is considered an empty array.
Raises Invalid_argument if the object is not an array.
val list : t -> t list
Extract the list of an Array object. Null is considered an empty list.
Raises Invalid_argument if the object is not a list.
val fold : (string -> t -> 'a -> 'a) -> t -> 'a -> 'a
Fold over all fields of the object. Null is considered an empty object. Typical usage is fold M.add t M.empty where M=Map.Make(String).
Raises Invalid_argument if the object is not an Assoc or Null object.
val field : string -> t -> t
Lookup a field in an object. Null is considered an empty object.
Raises