The JSON seam.
Config.json is a module. The default is Elixir's built-in JSON, and any
module exposing either the tagged or the bang API can be configured:
- tagged:
encode/1anddecode/1returning{:ok, value}/{:error, _}(Torque, Jason, Poison,LlmCall.JSON); - bang:
encode!/1anddecode!/1(Elixir'sJSON).
The facade functions encode/2 and decode/2 dispatch on what the module
exports and normalize the result to a tagged tuple, so a codec never raises on
a malformed payload. Configure the module at compile time with
config :llm_call, json_library: Torque, or per client with
json_library:.
A few wire fields are themselves JSON strings: tool-call arguments on OpenAI Chat, and streamed function calls on Gemini. A codec therefore needs a JSON implementation, and the caller may want a different one (Jason, a stricter encoder, a wrapped implementation with metrics).
Summary
Callbacks
Decodes a JSON binary.
The tagged adapter used by LlmCall.JSON itself, backed by Elixir JSON.
Callbacks
Functions
Decodes a binary with the configured module.
Encodes a term with the configured module.