Module Jsont.Array

Mapping JSON arrays.


type ('array, 'elt, 'builder) map

The type for mapping JSON arrays with elements of type 'elt to arrays of type 'array using values of type 'builder to build them.

type ('array, 'elt) enc = {
  1. enc : 'acc. Context.t -> ('acc -> int -> 'elt -> 'acc) -> 'acc -> 'array -> 'acc;

The type for specifying array encoding functions. A function to fold over the elements of type 'elt of the array of type 'array.

val map : ?kind:string -> ?doc:string -> dec_empty:(Context.t -> 'builder) -> ?dec_skip:(Context.t -> int -> 'builder -> bool) -> dec_add:(Context.t -> int -> 'elt -> 'builder -> 'builder) -> dec_finish:(Context.t -> Meta.t -> int -> 'builder -> 'array) -> enc:('array, 'elt) enc -> ?enc_meta:(Context.t -> '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 type 'a. Defaults to "".
  • doc is a documentation string for kind. Defaults to "".
  • dec_empty is used to create a builder for the empty array.
  • dec_add is used to add the ith JSON element to the builder.
  • dec_skip if true on the ith index of the JSON array, the element is not decoded with elt and not added with dec_add but skipped. Defaults returns always false.
  • dec_finish b converts the builder to the final array.
  • enc.enc ctx f acc v folds over the elements of array v in increasing order with f and starting with acc to encode it in a JSON array.
  • enc_meta v is the metadata to use for encoding v to a JSON array.
val list : ?kind:string -> ?doc:string -> ?dec_skip:(Context.t -> int -> 'a list -> bool) -> 'a t -> ('a list, 'a, 'a list) map

list elt maps JSON arrays with elements of type elt to list values. See also Jsont.list.

type 'a array_builder

The type for array builders.

val array : ?kind:string -> ?doc:string -> ?dec_skip:(Context.t -> int -> 'a array_builder -> bool) -> 'a t -> ('a array, 'a, 'a array_builder) map

array elt maps JSON arrays with elements of type elt to array values. See also Jsont.array.

type ('a, 'b, 'c) bigarray_builder

The type for bigarray_builders.

val bigarray : ?kind:string -> ?doc:string -> ?dec_skip:(Context.t -> 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

val type' : ('a, _, _) map -> 'a t

type' m maps with m 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.