Skip to main content

extract_json

Function extract_json 

Source
pub fn extract_json(text: &str) -> Result<Value>
Expand description

Pull the last JSON value out of a model response.

Models wrap JSON in prose or fences despite explicit instructions not to, and some emit a draft before the real answer, so the last well formed value wins: fenced blocks first, then brace matching backwards from the end.