Module Jsont.Array

JSON array maps.

Maps

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

The type for mapping JSON arrays to arrays of type 'array with elements of type 'elt and built with values of type 'builder.

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

The type for specifying array encoding maps. A function to fold over the elements of the array.

val map : ?kind:string -> ?doc:string -> dec_empty:(Context.t -> Meta.t -> 'array) -> dec_first:(Context.t -> 'elt -> 'builder) -> dec_next:(Context.t -> int -> 'elt -> 'builder -> 'builder) -> dec_finish:(Context.t -> Meta.t -> 'builder -> 'array) -> enc:('array, 'elt) enc -> enc_meta:(Context.t -> 'array -> Meta.t) -> 'elt t -> ('array, 'elt, 'builder) map

map defines an array map, the arguments are as follows:

  • kind names the entities represented by type 'a. Defaults to "".
  • doc is a documentation string for kind.
  • dec_empty () is used to decode an empty array.
  • dec_first v is used to create a array builder whose first element is v.
  • dec_next i v b adds v at index i of built array b.
  • dec_finish b is the array built by b.
  • enc.enc ctx f acc v folds over the elements of v in increasing order with f and starting with acc.
  • enc_meta v is the metadata to use for encoding.
  • elt is the type of elements in the array.

Predefined array maps

val list : ?kind:string -> ?doc:string -> 'a t -> ('a list, 'a, 'a list) map

list elt represents JSON arrays with elements of type elt by list values. See also Jsont.list.

type 'a array_builder

The type for array builders.

val array : ?kind:string -> ?doc:string -> 'a t -> ('a array, 'a, 'a array_builder) map

array elt represents JSON arrays with elements of type elt by array values. See also Jsont.array.

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

The type for bigarray_builders.

val bigarray : ?kind:string -> ?doc:string -> ('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 represents JSON arrays with elements of type elt by bigarray values of kind k and layout l. See also Jsont.bigarray.