Legend:
Library
Module
Module type
Parameter
Class
Class type
Library
Module
Module type
Parameter
Class
Class type
Support for json objects that contain a field that indicates the type of that object. The following
{
"type": "User",
"id": "abc123",
"age": 52
}
gets converted into a pair
[
"User",
{
"type": "User",
"id": "abc123",
"age": 52
}
]
A corresponding ATD type definition is
type obj = [
| User of user
| ...
] <json adapter.ocaml="Atdgen_runtime.Json_adapter.Type_field">
type user = {
id: string;
age: int;
(* The following field definition is supported, albeit useless. *)
type_ <json name="type">: string;
}
module type Param = sig ... end
module Default_param : Param
Default parameters, using type_field_name = "type"
.
Default adapter assuming a "type"
field.
include S
val normalize : Yojson.Safe.t -> Yojson.Safe.t
Convert a real json tree into an atd-compliant form.
val restore : Yojson.Safe.t -> Yojson.Safe.t
Convert an atd-compliant json tree into a real json tree.