Stop parsing LLM output with regex: return typed objects with Spring AI
therealdanvega · x · 2026-11-20
Dan Vega shares a practical tip: if your app makes decisions based on AI responses, don't parse text with regex — make the model return a structured type.
Using ticket triage as an example, define a Java record (priority, team, reason), then call .entity(Triage.class). Spring AI converts the record into a JSON schema and maps the response back, giving you a value you can validate, test, and switch on.
More from coding & agent
- MCP Events extension finalized in beta, ready for client and server adoption — dsp_ · 2026-11-21
- Gaussian splats in Godot: full tutorial plus using Fable agent to plan a pixel apartment layout — XRarchitect · 2026-11-21
- DevFest Pakistan 2026: deconstructing Gemini Deep Research with Antigravity 2.0 and Gemini 4 Neon — gerardsans · 2026-11-21
- mitsuhiko nudges GitHub to add an AI agent to 4-year-old merge=union feature request — mitsuhiko · 2026-11-21
- One dev orchestrates Fable, Opus and Astra to build a visually striking survival game — lyraxana · 2026-11-21
- JooVoice lets Grok, Muse and other agents make calls in 80+ languages to 67 countries — kimmonismus · 2026-11-21