package jsonoo

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type
type 'a encoder = 'a -> t

The type for encoder functions which turn ocaml values into JSON

val id : t encoder

Identity encoder which returns its argument unchanged

val null : t

The null JSON value

val bool : bool encoder

Encode a boolean into a JSON boolean

val float : float encoder

Encode a float as a JSON number

val int : int encoder

encode an integer as JSON number

val string : string encoder

Encode a string as a JSON string

val char : char encoder

Encode a character as a JSON string

val nullable : 'a encoder -> 'a option encoder

Encode a value with the decoder if Some, return a JSON null if None

val array : 'a encoder -> 'a array encoder

Encode an array as a JSON array

val list : 'a encoder -> 'a list encoder

Encode a list as a JSON array

val pair : 'a encoder -> 'b encoder -> ('a * 'b) encoder

Encode a 2-element tuple as a JSON array

val tuple2 : 'a encoder -> 'b encoder -> ('a * 'b) encoder

Encode a 2-element tuple as a JSON array

val tuple3 : 'a encoder -> 'b encoder -> 'c encoder -> ('a * 'b * 'c) encoder

Encode a 3-element tuple as a JSON array

val tuple4 : 'a encoder -> 'b encoder -> 'c encoder -> 'd encoder -> ('a * 'b * 'c * 'd) encoder

Encode a 4-element tuple as a JSON array

val dict : 'a encoder -> (string, 'a) Stdlib.Hashtbl.t encoder

Encode a hash table as a JSON dict

val object_ : (string * t) list encoder

Encode the pairs of keys and values as a JSON dict

OCaml

Innovation. Community. Security.