Decodes JSON into the structs of a generated SDK.
Every generated schema module defines __schema__/1:
__schema__(:fields):[{field_atom, "jsonName", type}], for objects__schema__(:type): the type, for schemas that aren't objects
Types:
:string | :integer | :number | :boolean | :null | :any
{:ref, module} # another schema
{:array, type}
{:map, type} # string keys to `type`
{:enum, ["a", "b"]} # stays a string
{:const, value}
{:union, [type], discriminator} # discriminator: nil | {"prop", %{"value" => module}}Decoding never crashes on data the SDK wasn't generated for: unknown fields
are kept in __extra__, unknown enum values stay strings, and a union
variant that matches nothing is returned as the raw map.
Summary
Functions
Decodes json (already parsed) as type.
Decodes json as the schema module.
Turns request data into JSON-ready terms: generated structs become maps
with their JSON names (fields left nil are dropped unless they were
present, and __extra__ is kept), atom keys and atom values become
strings. Used for request bodies, so callers can pass structs, maps or
keyword lists.
Functions
Decodes json (already parsed) as type.
Decodes json as the schema module.
Turns request data into JSON-ready terms: generated structs become maps
with their JSON names (fields left nil are dropped unless they were
present, and __extra__ is kept), atom keys and atom values become
strings. Used for request bodies, so callers can pass structs, maps or
keyword lists.