Atdgen_runtime.Json_adapterSourceJson adapters and tools for the user to make their own json adapters for common situations.
Json adapters are used to rewrite json node into a form compatible with atdgen's conventions.
Module signature required of any json adapter. For example, an ATD annotation <json adapter.ocaml="Atdgen_runtime.Json_adapter.Type_field" refers to the OCaml module Atdgen_runtime.Json_adapter.Type_field.
Support for json objects that contain a field that indicates the type of that object. The following
Alternatively, function-based definition of the JSON adapter is supported. For example, an ATD annotation <json adapter.to_ocaml="Atdgen_runtime.Json_adapter.normalize_type_field \"type\"" adapter.from_ocaml="Atdgen_runtime.Json_adapter.restore_type_field \"type\""> specifies two functions Yojson.Safe.t -> Yojson.Safe.t and in this case functionally equivalent to <json adapter.ocaml="Atdgen_runtime.Json_adapter.Type_field".
The form could be useful though, when more specific per-type data processing is needed and defining the new module for each case could become cumbersome.
Normalize JSON representation, as specified in Type_field
Restore JSON representation, as specified in Type_field
Support for objects with a single field whose name indicates the type of the value. For instance,
Support for the retired tag_field feature. This converts the following