Skip to main content

Module json_extract

Module json_extract 

Source
Expand description

JSON extraction from raw LLM text output. Extract structured JSON from raw LLM text output.

LLMs often wrap JSON in markdown code fences or add prose around it. This module handles the common cases:

  • ```json ... ``` fenced blocks
  • ``` ... ``` fences with JSON inside
  • Raw balanced-bracket JSON buried in text

Structs§

JsonExtractor
Type-safe JSON extraction wrapper for use with LLM clients.

Enums§

ParseJsonError
Error from parse_json.

Functions§

extract_json
Extract the first JSON object or array from raw LLM text.
extract_xml_tag
Extract the content of a named XML tag from raw LLM text.
parse_json
Parse LLM output into a typed struct using extract_json + serde_json.