AnanthaJson.JsonAdapter (llm_utils v0.1.1)

Copy Markdown View Source

Defensive JSON decoder that tries JsonRemedy.repair/1 first for malformed LLM output, falling back to Jason.decode/2.

This decouples the pipeline from the json_remedy dependency. If json_remedy is unavailable (e.g. not compiled), we silently fall back to standard JSON decoding.

Summary

Functions

Decodes a JSON string, attempting repair first.

Like decode/1 but raises on error.

Functions

decode(json_string)

@spec decode(String.t()) :: {:ok, term()} | {:error, term()}

Decodes a JSON string, attempting repair first.

Returns {:ok, decoded} on success or {:error, reason} on failure.

decode!(json_string)

@spec decode!(String.t()) :: term()

Like decode/1 but raises on error.