package json-data-encoding
Install
dune-project
Dependency
Authors
Maintainers
Sources
md5=24fcb7feb10395eaaf840d1f8ccf162f
sha512=f6d2a00008a0cd88bfae2458f56dde8f45c4e209ece9805d3e8d2c74401e4a5f9e12f99d5318f58a30a4579d9c9e9f204a75269c2110bb16a3e1036b2599b7a5
doc/json-data-encoding/Json_repr/index.html
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:(Format.formatter -> string -> unit) ->
(module Repr with type value = 'tf) ->
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.
*)| `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.
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:(Format.formatter -> string -> unit) ->
unit ->
Format.formatter ->
any ->
unitPredefined converters for ezjsonm
see ezjsonm