Every developer who has worked with LLMs has been there. You ask the model for JSON. You describe the schema. You say "please only respond with valid JSON." And sometimes, it still breaks.
Your application crashes because the model returned a string where you expected an integer. Or it wrapped the JSON in markdown code blocks. Or it omitted a required field.
Spring AI 2.0 has a solution that treats this like a real engineering problem instead of a prayer.
The Problem
When you use structured output in Spring AI, the workflow goes like this:






