package jsont
Install
Dune Dependency
Authors
Maintainers
Sources
sha512=e3f403d12283ac932b08254bf5d5debd3dbec1c9022e21f69b1be3fb74727da3ae7d26510eba6770451a6c711987884d93a3ee5baa94ca3a07166ad779206da5
doc/jsont/Jsont/Array/index.html
Module Jsont.Array
Mapping JSON arrays.
Maps
The type for specifying array encoding functions. A function to fold over the elements of type 'elt
of the array of type 'array
.
The type for mapping JSON arrays with elements of type 'elt
to arrays of type 'array
using values of type 'builder
to build them.
val map :
?kind:string ->
?doc:string ->
?dec_empty:(unit -> 'builder) ->
?dec_skip:(int -> 'builder -> bool) ->
?dec_add:(int -> 'elt -> 'builder -> 'builder) ->
?dec_finish:(Meta.t -> int -> 'builder -> 'array) ->
?enc:('array, 'elt) enc ->
?enc_meta:('array -> Meta.t) ->
'elt t ->
('array, 'elt, 'builder) map
map elt
maps JSON arrays of type 'elt
to arrays of type 'array
built with type 'builder
.
kind
names the entities represented by the map anddoc
documents them. Both default to""
.dec_empty ()
is used to create a builder for the empty array. Can be omitted if the map is only used for encoding, the default unconditionally errors.dec_skip i b
is used to skip thei
th index of the JSON array. Iftrue
, the element is not decoded withelt
and not added withdec_add
but skipped. The default always returnsfalse
.dec_add i v
is used to add thei
th JSON elementv
$ decoded byelt
to the builderb
. Can be omitted if the map is only used for encoding, the default unconditionally errors.dec_finish b
converts the builder to the final array. Can be omitted if the map is only used for encoding, the default unconditionally errors.enc.enc f acc a
folds over the elements of arraya
in increasing order withf
and starting withacc
. This function is used to encodea
to a JSON array. Can be omitted if the map is only used for decoding, the default unconditionally errors.enc_meta a
is the metadata to use for encodingv
to a JSON array. Default returnsMeta.none
.
val list_map :
?kind:string ->
?doc:string ->
?dec_skip:(int -> 'a list -> bool) ->
'a t ->
('a list, 'a, 'a list) map
list_map elt
maps JSON arrays with elements of type elt
to list
values. See also Jsont.list
.
val array_map :
?kind:string ->
?doc:string ->
?dec_skip:(int -> 'a array_builder -> bool) ->
'a t ->
('a array, 'a, 'a array_builder) map
array_map elt
maps JSON arrays with elements of type elt
to array
values. See also Jsont.array
.
val bigarray_map :
?kind:string ->
?doc:string ->
?dec_skip:(int -> ('a, 'b, 'c) bigarray_builder -> bool) ->
('a, 'b) Bigarray.kind ->
'c Bigarray.layout ->
'a t ->
(('a, 'b, 'c) Bigarray.Array1.t, 'a, ('a, 'b, 'c) bigarray_builder) map
bigarray k l elt
maps JSON arrays with elements of type elt
to bigarray values of kind k
and layout l
. See also Jsont.bigarray
.
JSON types
array map
maps with map
JSON arrays to values of type 'a
. See the the array combinators.
val ignore : unit t
ignore
ignores JSON arrays on decoding and errors on encoding.
val zero : unit t
zero
ignores JSON arrays on decoding and encodes an empty array.