Jsont.BaseMapping JSON base types.
val map :
?kind:string ->
?doc:string ->
?dec:(Meta.t -> 'a -> 'b) ->
?enc:('b -> 'a) ->
?enc_meta:('b -> Meta.t) ->
unit ->
('a, 'b) mapmap ~kind ~doc ~dec ~enc ~enc_meta () maps JSON base types represented by value of type 'a to values of type 'b with:
kind names the entities represented by the map and doc documents them. Both default to "".dec is used to decode values of type 'a to values of type 'b. Can be omitted if the map is only used for encoding, the default unconditionally errors.enc is used to encode values of type 'b to values of type 'a. Can be omitted if the map is only used for decoding, the default unconditionally errors.enc_meta is used to recover JSON metadata (source text layout information) from a value to encode. The default unconditionnaly returns Jsont.Meta.none.These functions can be used to quickly devise dec and enc functions from standard OCaml conversion interfaces.
val id : ('a, 'a) mapid is the identity map.
val ignore : ('a, unit) mapignore is the ignoring map. It ignores decodes and errors on encodes.
null map maps with map JSON nulls represented by () to values of type 'a. See also Jsont.null.
bool map maps with map JSON booleans represented by bool values to values of type 'a. See also Jsont.bool.
number map maps with map JSON nulls or numbers represented by float values to values of type 'a. The float representation decodes JSON nulls to Float.nan and lossily encodes any non-finite to JSON null (explanation). See also Jsont.number.
string map maps with map unescaped JSON strings represented by UTF-8 encoded string values to values of type 'a. See also Jsont.string.
These function create suitable dec and enc functions to give to map from standard OCaml conversion interfaces. See also Jsont.of_of_string.
val dec : ('a -> 'b) -> Meta.t -> 'a -> 'bdec f is a decoding function from f. This assumes f never fails.
val dec_result :
?kind:string ->
('a -> ('b, string) Stdlib.result) ->
Meta.t ->
'a ->
'bdec f is a decoding function from f. Error _ values are given to Error.msg, prefixed by kind: (if specified).
val dec_failure : ?kind:string -> ('a -> 'b) -> Meta.t -> 'a -> 'bdec f is a decoding function from f. Failure _ exceptions are catched and given to Error.msg, prefixed by kind: (if specified).
enc_result f is an encoding function from f. Error _ values are given to Error.msg, prefixed by kind: (if specified).
enc_failure f is an encoding function from f. Failure _ exceptions are catched and given to Error.msg, prefixed by kind: (if specified).