Sycophant.Serializable.Decoder (sycophant v0.5.0)

Copy Markdown

Decodes plain maps back into Sycophant structs using their "__type__" discriminator. Most types decode through their Zoi schema (t/0); a few containers post-process (tool function registry, resolved schema, etc.).

Summary

Functions

Decodes a JSON string back into a Sycophant struct.

Serializes a struct to a JSON string.

Reconstructs a Sycophant struct from a plain map via its __type__.

Functions

decode(json, opts \\ [])

@spec decode(
  String.t(),
  keyword()
) :: struct()

Decodes a JSON string back into a Sycophant struct.

encode(struct)

@spec encode(struct()) :: String.t()

Serializes a struct to a JSON string.

from_map(data, opts \\ [])

@spec from_map(
  map(),
  keyword()
) :: struct()

Reconstructs a Sycophant struct from a plain map via its __type__.