A2aEngine.Codec.Keys (a2a_engine v0.1.0)

Copy Markdown View Source

Key-case conversion between A2A wire format (camelCase strings) and Elixir conventions (snake_case atoms).

  • to_wire/1 — struct/map/list → camelCase-keyed map (strings), recursive
  • from_wire/1 — camelCase-keyed map → snake_case atom-keyed map, recursive

Both preserve values unchanged; only keys are transformed.

Summary

Functions

Recursively snake_case-ify map keys into atoms. Preserves non-map/list values. Uses String.to_atom/1 to accept unknown keys — only call on trusted input sources (the A2A spec has a known key set).

Recursively camelCase-ify map keys. Preserves non-map/list values. Atom keys are stringified; string keys are camelized; other keys pass through.

Functions

from_wire(map)

@spec from_wire(any()) :: any()

Recursively snake_case-ify map keys into atoms. Preserves non-map/list values. Uses String.to_atom/1 to accept unknown keys — only call on trusted input sources (the A2A spec has a known key set).

to_wire(map)

@spec to_wire(any()) :: any()

Recursively camelCase-ify map keys. Preserves non-map/list values. Atom keys are stringified; string keys are camelized; other keys pass through.