Claude returned ```json blocks 14% of the time. Here is the Rust crate I wish I had earlier.
The article discusses the challenges of obtaining valid JSON responses from the Claude AI model. It highlights that 14% of the responses were not parseable as JSON due to various issues. To address this, the author created a Rust crate called llm-json-repair that performs three passes to clean up the responses before they are processed further.
- ▪Claude AI returned valid JSON 86% of the time during structured-output calls.
- ▪Common issues included JSON wrappers, leading or trailing prose, and trailing commas.
- ▪The llm-json-repair crate performs three passes to clean up the responses, improving their parseability.
Opening excerpt (first ~120 words) tap to expand
try { if(localStorage) { let currentUser = localStorage.getItem('current_user'); if (currentUser) { currentUser = JSON.parse(currentUser); if (currentUser.id === 3915555) { document.getElementById('article-show-container').classList.add('current-user-is-article-author'); } } } } catch (e) { console.error(e); } Mukunda Rao Katta Posted on May 21 Claude returned ```json blocks 14% of the time. Here is the Rust crate I wish I had earlier. #hermesagent #ai #llm #rust I had a system prompt that ended with: Reply with only a JSON object. Do not include code fences. Do not include explanation. That should be enough. It is not.
…
Excerpt limited to ~120 words for fair-use compliance. The full article is at DEV.to (Top).