Page
Library
Module
Module type
Parameter
Class
Class type
Source
Yojson.RawSourceInts, floats and strings literals are systematically preserved using `Intlit, `Floatlit and `Stringlit. This module also supports the specific syntax for variants and tuples supported by Yojson.Safe.
type json = [ | `Null| `Bool of bool| `Intlit of string| `Floatlit of string| `Stringlit of string| `Assoc of (string * json) list| `List of json list| `Tuple of json list| `Variant of string * json option ]All possible cases defined in Yojson:
("abc", 123).<"Foo"> or <"Bar":123>.Write a compact JSON value to a string.
Write a compact JSON value to a channel.
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 ->
unitWrite a compact JSON value to an OO channel.
See to_string for the role of the other optional arguments.
Write a compact JSON value to a file. See to_string for the role of the optional arguments.
Write a compact JSON value to an existing buffer. See to_string for the role of the optional argument.
Write a newline-separated sequence of compact one-line JSON values to a string. See to_string for the role of the optional arguments.
val stream_to_channel :
?buf:Bi_outbuf.t ->
?len:int ->
?std:bool ->
out_channel ->
json Stream.t ->
unitWrite a newline-separated sequence of compact one-line JSON values to a channel. See to_channel for the role of the optional arguments.
Write a newline-separated sequence of compact one-line JSON values to a file. See to_string for the role of the optional arguments.
Write a newline-separated sequence of compact one-line JSON values to an existing buffer. See to_string for the role of the optional arguments.
Sort object fields (stable sort, comparing field names and treating them as byte sequences)
Convert into a pretty-printable tree. See to_string for the role of the optional std argument.
Pretty-print into a Format.formatter. See to_string for the role of the optional std argument.
Pretty-print into a string. See to_string for the role of the optional std argument.
Pretty-print to a channel. See to_string for the role of the optional std argument.
Combined parser and pretty-printer. See to_string for the role of the optional std argument.
Combined parser and printer. See to_string for the role of the optional std argument.
Read a JSON value from a string.
Read a JSON value from a channel. See from_string for the meaning of the optional arguments.
Read a JSON value from a file. See from_string for the meaning of the optional arguments.
type lexer_state = Lexer_state.t = {buf : Bi_outbuf.t;mutable lnum : int;mutable bol : int;mutable fname : string option;}This alias is provided for backward compatibility. New code should refer to Yojson.lexer_state directly.
This alias is provided for backward compatibility. New code should use Yojson.init_lexer directly.
Read a JSON value from a lexbuf. A valid initial lexer_state can be created with init_lexer. See from_string for the meaning of the optional arguments.
val stream_from_string :
?buf:Bi_outbuf.t ->
?fname:string ->
?lnum:int ->
string ->
json Stream.tInput a sequence of JSON values from a string. Whitespace between JSON values is fine but not required. See from_string for the meaning of the optional arguments.
val stream_from_channel :
?buf:Bi_outbuf.t ->
?fin:(unit -> unit) ->
?fname:string ->
?lnum:int ->
in_channel ->
json Stream.tInput a sequence of JSON values from a channel. Whitespace between JSON values is fine but not required.
See from_string for the meaning of the other optional arguments.
val stream_from_file :
?buf:Bi_outbuf.t ->
?fname:string ->
?lnum:int ->
string ->
json Stream.tInput a sequence of JSON values from a file. Whitespace between JSON values is fine but not required.
See from_string for the meaning of the optional arguments.
Input a sequence of JSON values from a lexbuf. A valid initial lexer_state can be created with init_lexer. Whitespace between JSON values is fine but not required.
See stream_from_channel for the meaning of the optional fin argument.
The type of values resulting from a parsing attempt of a JSON value.
val linestream_from_channel :
?buf:Bi_outbuf.t ->
?fin:(unit -> unit) ->
?fname:string ->
?lnum:int ->
in_channel ->
json_line Stream.tInput a sequence of JSON values, one per line, from a channel. Exceptions raised when reading malformed lines are caught and represented using `Exn.
See stream_from_channel for the meaning of the optional fin argument. See from_string for the meaning of the other optional arguments.
val linestream_from_file :
?buf:Bi_outbuf.t ->
?fname:string ->
?lnum:int ->
string ->
json_line Stream.tInput a sequence of JSON values, one per line, from a file. Exceptions raised when reading malformed lines are caught and represented using `Exn.
See stream_from_channel for the meaning of the optional fin argument. See from_string for the meaning of the other optional arguments.