pub fn extract_json_blocks(input: &str) -> Vec<&str>Expand description
Extract all top-level JSON payloads from raw LLM output.
Scans the input (after unwrapping a surrounding code fence, if any) for
balanced {...} / [...] blocks. A final unbalanced block (truncated
LLM output) is included as the last element so the sanitize stage can
close it.
ยงExample
use fuzzy_parser::extract_json_blocks;
let output = r#"First: {"a": 1} and second: {"b": 2}"#;
let blocks = extract_json_blocks(output);
assert_eq!(blocks, vec![r#"{"a": 1}"#, r#"{"b": 2}"#]);