module Yojson:The Yojson library provides runtime functions for reading and writing JSON data from OCaml. It addresses a few shortcomings of its predecessor json-wheel and is about twice as fast (2.7x reading, 1.3x writing; results may vary). The design goals of Yojson are the following:sig
..end
val version : string
exception Json_error of string
val json_error : string -> 'a
type
lexer_state = {
|
buf : |
(* | Buffer used to accumulate substrings | *) |
|
mutable lnum : |
(* | Current line number (counting from 1) | *) |
|
mutable bol : |
(* | Absolute position of the first character of the current line (counting from 0) | *) |
|
mutable fname : |
(* | Name referencing the input file in error messages | *) |
module Lexer_state:sig
..end
val init_lexer : ?buf:Bi_outbuf.t -> ?fname:string -> ?lnum:int -> unit -> lexer_state
module Basic:sig
..end
module Safe:sig
..end
module Raw:sig
..end
typejson =
[ `Assoc of (string * json) list
| `Bool of bool
| `Float of float
| `Floatlit of string
| `Int of int
| `Intlit of string
| `List of json list
| `Null
| `String of string
| `Stringlit of string
| `Tuple of json list
| `Variant of string * json option ]
("abc", 123)
.<"Foo">
or <"Bar":123>
.typejson_max =
json
val to_string : ?buf:Bi_outbuf.t -> ?len:int -> ?std:bool -> json -> string
buf
: allows to reuse an existing buffer created with
Bi_outbuf.create
. The buffer is cleared of all contents
before starting and right before returning.len
: initial length of the output buffer.std
: use only standard JSON syntax,
i.e. convert tuples and variants into standard JSON (if applicable),
refuse to print NaN and infinities,
require the root node to be either an object or an array.
Default is false
.val to_channel : ?buf:Bi_outbuf.t ->
?len:int -> ?std:bool -> Pervasives.out_channel -> json -> unit
buf
: allows to reuse an existing buffer created with
Bi_outbuf.create_channel_writer
on the same channel.
buf
is flushed right
before to_channel
returns but the out_channel
is
not flushed automatically.
See to_string
for the role of the other optional arguments.
val to_output : ?buf:Bi_outbuf.t ->
?len:int ->
?std:bool ->
< output : string -> int -> int -> int; .. > -> json -> unit
buf
: allows to reuse an existing buffer created with
Bi_outbuf.create_output_writer
on the same channel.
buf
is flushed right
before to_output
returns but the channel itself is
not flushed automatically.
See to_string
for the role of the other optional arguments.
val to_file : ?len:int -> ?std:bool -> string -> json -> unit
to_string
for the role of the optional arguments.val to_outbuf : ?std:bool -> Bi_outbuf.t -> json -> unit
to_string
for the role of the optional argument.val stream_to_string : ?buf:Bi_outbuf.t -> ?len:int -> ?std:bool -> json Stream.t -> string
to_string
for the role of the optional arguments.val stream_to_channel : ?buf:Bi_outbuf.t ->
?len:int ->
?std:bool -> Pervasives.out_channel -> json Stream.t -> unit
to_channel
for the role of the optional arguments.val stream_to_file : ?len:int -> ?std:bool -> string -> json Stream.t -> unit
to_string
for the role of the optional arguments.val stream_to_outbuf : ?std:bool -> Bi_outbuf.t -> json Stream.t -> unit
to_string
for the role of the optional arguments.val pretty_format : ?std:bool -> json -> Easy_format.t
to_string
for the role of the optional std
argument.val pretty_to_string : ?std:bool -> json -> string
to_string
for the role of the optional std
argument.val pretty_to_channel : ?std:bool -> Pervasives.out_channel -> json -> unit
to_string
for the role of the optional std
argument.