package json-data-encoding
Module Json_reprSource
Representations of JSON documents
Abstraction over JSON representations
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
*)trueorfalse.| `Float of float(*A floating point number (double precision).
*)| `String of string(*An UTF-8 encoded string.
*)| `Null(*The
*)nullconstant.
]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 uids 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.
val convert :
(module Repr with type value = 'tf) ->
(module Repr with type value = 'tt) ->
'tf ->
'ttConvert a JSON value from one representation to another.
val pp :
?compact:bool ->
?pp_string:(Json_data_encoding_stdlib.Format.formatter -> string -> unit) ->
(module Repr with type value = 'tf) ->
Json_data_encoding_stdlib.Format.formatter ->
'tf ->
unitGeneric pretty-printer. If compact is set (by default), then the output is not really pretty (no space is output). Ascii-compatible string encoding is expected, as printing only escapes double quotes and control characters. Use pp_string for more advanced escaping. This function does not claim to be the best JSON pretty printer, it is mostly a small utility.
Third party in-memory JSON document representations
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
*)trueorfalse.| `Float of float(*A floating point number (double precision).
*)| `String of string(*An UTF-8 encoded string.
*)| `Null(*The
*)nullconstant.
]A JSON value compatible with Ezjsonm.value.
type yojson = [ | `Bool of bool(*A JS boolean
*)trueoffalse.| `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
*)nullconstant.| `String of string(*An UTF-8 encoded string.
*)
]A JSON value compatible with Yojson.Safe.json.
Representation-agnostic JSON format
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.
val pp_any :
?compact:bool ->
?pp_string:(Json_data_encoding_stdlib.Format.formatter -> string -> unit) ->
unit ->
Json_data_encoding_stdlib.Format.formatter ->
any ->
unitPredefined converters for ezjsonm
see ezjsonm