beginner~2h
Structured Output
An LLM generates text. Your service layer wants a Java object. This module is the bridge — and where it can quietly go wrong.
Learning objectives
- Beginner: A single.entity(SomeRecord.class) call for a simple extraction task, with low temperature.
- Intermediate: ParameterizedTypeReference for a list of extracted entities, with try/catch around parse failures and a retry (see Module 16's runtime validation pattern).
- Advanced: Native structured output for a provider that supports it, combined with a FactCheckingEvaluator (Module 16) so both the shape and the substance of the response are verified before it reaches a downstream system.
This is a Pro chapter
Sign in, then upgrade to Pro or Power to unlock this and the full Spring Ecosystem Mastery library.
Structured Output