package jsont

  1. Overview
  2. Docs
Declarative JSON data manipulation for OCaml

Install

dune-project
 Dependency

Authors

Maintainers

Sources

jsont-0.2.0.tbz
sha512=6206f73a66cb170b560a72e58f70b9fb2c20397b9ab819dceba49b6602b9b79e47ba307e6910e61ca4694555c66fdcd7a17490afb99548e8f43845a5a88913e7

doc/jsont/Jsont/Array/index.html

Module Jsont.ArraySource

Mapping JSON arrays.

Maps

Sourcetype ('array, 'elt) enc = {
  1. enc : 'acc. ('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.

Sourcetype ('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.

Sourceval 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 and doc 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 the ith index of the JSON array. If true, the element is not decoded with elt and not added with dec_add but skipped. The default always returns false.
  • dec_add i v is used to add the ith JSON element v $ decoded by elt to the builder b. 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 array a in increasing order with f and starting with acc. This function is used to encode a 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 encoding v to a JSON array. Default returns Meta.none.
Sourceval 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.

Sourcetype 'a array_builder

The type for array builders.

Sourceval 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.

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

The type for bigarray_builders.

Sourceval 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

Sourceval array : ('a, _, _) map -> 'a t

array map maps with map JSON arrays to values of type 'a. See the the array combinators.

Sourceval ignore : unit t

ignore ignores JSON arrays on decoding and errors on encoding.

Sourceval zero : unit t

zero ignores JSON arrays on decoding and encodes an empty array.

OCaml

Innovation. Community. Security.

On This Page
  1. Maps
  2. JSON types