"Return your answer as JSON" followed by JSON.parse() is one of the most common — and most fragile — patterns in LLM apps. The model adds a preamble, wraps it in a code fence, trails a comment, and your parser throws in production. Structured outputs fix this by constraining the model to a schema instead of hoping it behaves.
Why prose-parsing fails
When you ask for JSON in plain text, you're relying on the model to:
- emit only JSON (no "Here's your result:"),
- close every bracket and quote,
- use the exact field names you expect,
- never hallucinate an extra field.
At low volume it mostly works. At production volume, "mostly" means a steady trickle of 500s and silent data corruption. Regex cleanup is a losing battle.
The fix: constrain to a schema
Define the shape you want and have the framework enforce it — either via a JSON schema passed to the model or a typed mapping that validates the response. You stop parsing prose and start receiving objects.