pub fn parse_llm_json<T: DeserializeOwned>(
raw: &str,
) -> Result<T, LlmJsonParseError>Expand description
Parses LLM JSON output with automatic repair of common errors.
Applies these repairs in order:
- Strip markdown code fences (
json ...) - Find the outermost JSON bracket pair
- Remove trailing commas before
}or] - Fix unescaped inner quotes within string values (heuristic)
- Truncate to the last matching
}or]if there’s trailing garbage
Returns the deserialized value or an error if repair fails.