Library
Module
Module type
Parameter
Class
Class type
Representations of JSON documents
type 'a view = [
| `O of (string * 'a) list
An associative table (object).
*)| `A of 'a list
An (integer indexed) array.
*)| `Bool of bool
A JS boolean true
or false
.
| `Float of float
A floating point number (double precision).
*)| `String of string
An UTF-8 encoded string.
*)| `Null
The null
constant.
]
The internal format used by the library. A common format to view JSON structures from different representations. It only shows the head of structures, hiding the contents of fields, so that the conversion from another format or a stream can be done lazily.
Each representation must provide a unique identifier, obtained via the repr_uid
function. This identifier is used when converting between representations, to optimize out a copy when converting from a representation to itself. Beware that this optimization relies only on this uid
token. Converting between values of the same type using two different representation modules with different uid
s will perform a copy. A practical way to ensure that the optimization is made is to write your representations as toplevel modules, and not inside functors.
module type Repr = sig ... end
A view over a given implementation.
val convert :
(module Repr with type value = 'tf) ->
(module Repr with type value = 'tt) ->
'tf ->
'tt
Convert a JSON value from one representation to another.
type ezjsonm = [
| `O of (string * ezjsonm) list
An associative table (object).
*)| `A of ezjsonm list
An (integer indexed) array.
*)| `Bool of bool
A JS boolean true
or false
.
| `Float of float
A floating point number (double precision).
*)| `String of string
An UTF-8 encoded string.
*)| `Null
The null
constant.
]
A JSON value compatible with Ezjsonm.value
.
type yojson = [
| `Bool of bool
A JS boolean true
of false
.
| `Assoc of (string * yojson) list
JSON object.
*)| `Float of float
A floating point number (double precision).
*)| `Int of int
A number without decimal point or exponent.
*)| `Intlit of string
A number without decimal point or exponent, preserved as string.
*)| `List of yojson list
A JS array.
*)| `Null
The null
constant.
| `String of string
An UTF-8 encoded string.
*)| `Tuple of yojson list
A tuple (non-standard). Syntax: ("abc", 123).
*)| `Variant of string * yojson option
A variant (non-standard). Syntax: <"Foo"> or <"Bar": 123>.
*) ]
A JSON value compatible with Yojson.Safe.json
.
A meta-representation for JSON values that can unify values of different representations by boxing them with their corresponding Repr
modules.
Converts a boxed value from its intrinsic representation to the one of the given Repr
module. Optimized if the internal representation of the value actually is the requested one.
Boxes a value with a compatible Repr
module.
ezjsonm