Module Tpf_json.Dec
Generic JSON decoder.
Records are expected as JSON objects, and constant constructors are expected as JSON strings.
The representation of variants is determined by the ~sum
argument (default arr
).
Generic function
type sum
= (string * json list) d
Sum-destructuring functions.
f json
isOk (name, args)
whenjson
encodes a constructor namedname
with argumentsargs
, orError _
otherwise.
val arr : sum
Destructures
K (a0, a1, ...)
from["K", a0, a1, ...]
.
val obj : ?tag:string -> ?values:string -> sum
Destructures
K (a0, a1, ...)
from{ tag: "K", values: [a0, a1, ...]}
.tag
defaults to"tag"
andvalues
defaults to"values"
.
val g_of_json : ?sum:sum -> ('a, p) Tpf.schema -> 'a d
data
interface
val data0 : ?sum:sum -> 'x Tpf.data0 -> 'x d
val data1 : ?sum:sum -> ('a, 'x) Tpf.data1 -> 'a d -> 'x d
val data2 : ?sum:sum -> ('a, 'b, 'x) Tpf.data2 -> 'a d -> 'b d -> 'x d
val data3 : ?sum:sum -> ('a, 'b, 'c, 'x) Tpf.data3 -> 'a d -> 'b d -> 'c d -> 'x d
val data4 : ?sum:sum -> ('a, 'b, 'c, 'd, 'x) Tpf.data4 -> 'a d -> 'b d -> 'c d -> 'd d -> 'x d
val data5 : ?sum:sum -> ('a, 'b, 'c, 'd, 'e, 'x) Tpf.data5 -> 'a d -> 'b d -> 'c d -> 'd d -> 'e d -> 'x d
val data6 : ?sum:sum -> ('a, 'b, 'c, 'd, 'e, 'f, 'x) Tpf.data6 -> 'a d -> 'b d -> 'c d -> 'd d -> 'e d -> 'f d -> 'x d
val data7 : ?sum:sum -> ('a, 'b, 'c, 'd, 'e, 'f, 'g, 'x) Tpf.data7 -> 'a d -> 'b d -> 'c d -> 'd d -> 'e d -> 'f d -> 'g d -> 'x d
val data8 : ?sum:sum -> ('a, 'b, 'c, 'd, 'e, 'f, 'g, 'h, 'x) Tpf.data8 -> 'a d -> 'b d -> 'c d -> 'd d -> 'e d -> 'f d -> 'g d -> 'h d -> 'x d
val data9 : ?sum:sum -> ('a, 'b, 'c, 'd, 'e, 'f, 'g, 'h, 'i, 'x) Tpf.data9 -> 'a d -> 'b d -> 'c d -> 'd d -> 'e d -> 'f d -> 'g d -> 'h d -> 'i d -> 'x d