package atdgen-runtime

  1. Overview
  2. Docs

Support for objects with a single field whose name indicates the type of the value. For instance,

{
  "User": {
    "id": "abc123",
    "age": 52
  }
}

gets converted into

[
  "User",
  {
    "id": "abc123",
    "age": 52
  }
]

An ATD type definition for this is

type obj = [
  | User of user
  | ...
] <json adapter.ocaml="Atdgen_runtime.Json_adapter.One_field">

type user = {
  id: string;
  age: int;
}
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.

OCaml

Innovation. Community. Security.