Page
Library
Module
Module type
Parameter
Class
Class type
Source
YojsonThe Yojson library provides several types for representing JSON values, with different use cases.
Each of these different types have their own module.
Exception used:
float value is not allowed in standard JSON.type lexer_state = {buf : Buffer.t;Buffer used to accumulate substrings
*)mutable lnum : int;Current line number (counting from 1)
*)mutable bol : int;Absolute position of the first character of the current line (counting from 0)
*)mutable fname : string option;Name referencing the input file in error messages
*)}module Lexer_state : sig ... endval init_lexer :
?buf:Buffer.t ->
?fname:string ->
?lnum:int ->
unit ->
lexer_stateCreate a fresh lexer_state record.
type t = [ | `Null| `Bool of bool| `Int of int| `Intlit of string| `Float of float| `Floatlit of string| `String of string| `Stringlit of string| `Assoc of (string * t) list| `List of t list| `Tuple of t list| `Variant of string * t option ]All possible cases defined in Yojson:
("abc", 123).<"Foo"> or <"Bar":123>.val pp : Format.formatter -> t -> unitPretty printer, useful for debugging
val show : t -> stringConvert value to string, useful for debugging
equal a b is the monomorphic equality. Determines whether two JSON values are considered equal. In the case of JSON objects, the order of the keys does not matter, except for duplicate keys which will be considered equal as long as they are in the same input order.
Write a compact JSON value to a string.
val to_channel :
?buf:Buffer.t ->
?len:int ->
?suf:string ->
?std:bool ->
out_channel ->
t ->
unitWrite a compact JSON value to a channel. Note: the out_channel is not flushed by this function.
See to_string for the role of the optional arguments and raised exceptions.
val to_output :
?buf:Buffer.t ->
?len:int ->
?suf:string ->
?std:bool ->
< output : string -> int -> int -> int.. > ->
t ->
unitWrite a compact JSON value to an OO channel.
See to_string for the role of the optional arguments and raised exceptions.
val to_file : ?len:int -> ?std:bool -> ?suf:string -> string -> t -> unitWrite a compact JSON value to a file. See to_string for the role of the optional arguments and raised exceptions.
Write a compact JSON value to an existing buffer. See to_string for the role of the optional argument and raised exceptions.
Write a sequence of suf-suffixed compact one-line JSON values to a string.
val seq_to_channel :
?buf:Buffer.t ->
?len:int ->
?suf:string ->
?std:bool ->
out_channel ->
t Seq.t ->
unitWrite a sequence of suf-suffixed compact one-line JSON values to a channel.
Write a sequence of suf-suffixed compact one-line JSON values to a file.
Write a sequence of suf-suffixed compact one-line JSON values to an existing buffer.
Write the given JSON value to the given buffer. Provided as a writer function for atdgen.
Sort object fields (stable sort, comparing field names and treating them as byte sequences)
val pretty_print : ?std:bool -> Format.formatter -> t -> unitPretty-print into a Format.formatter. See to_string for the role of the optional std argument.
val pretty_to_string : ?std:bool -> t -> stringPretty-print into a string. See to_string for the role of the optional std argument. See pretty_print for raised exceptions.
val pretty_to_channel : ?std:bool -> out_channel -> t -> unitPretty-print to a channel. See to_string for the role of the optional std argument. See pretty_print for raised exceptions.
module Basic : sig ... endThis module supports standard JSON nodes only, i.e. no special syntax for variants or tuples as supported by Yojson.Safe. Arbitrary integers are not supported as they must all fit within the standard OCaml int type (31 or 63 bits depending on the platform).
module Safe : sig ... endThis module supports a specific syntax for variants and tuples in addition to the standard JSON nodes. Arbitrary integers are supported and represented as a decimal string using `Intlit when they cannot be represented using OCaml's int type (31 or 63 bits depending on the platform).
module Raw : sig ... endInts, 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.