liveBook · Manning

Structured data

As explained in Build AI-Enhanced Web Apps

Structured data is data organized according to an explicit schema or predictable structure that enables machine processing.

Structured data gives an AI response a predictable shape instead of leaving it as raw text. In a product-search interface, JSON product records can be validated, stored in the conversation, and rendered as a table. section 4.3.4

A React implementation follows the response from model to screen:

  • Define the expected product shape with a Zod schema, then use the Vercel AI SDK’s generateObject helper to request and validate JSON against it. section 4.3.4
  • Expose the product-generation server action through createAI. On form submission, call the action with the user’s request and add the returned products to the conversation. section 4.3.4
  • Render product fields in a table. Handle generation failures rather than assuming every request returns usable data. section 4.3.4
Listing 4.11 Including the generateProductList action
export const AI = createAI({
  actions: {
    generateProductList,    #1
  },
  initialAIState: [],
  initialUIState: [],
});

The action registration shows where structured product generation enters the application’s AI interface. section 4.3.4

Provider capabilities matter. In a separate LangChain.js integration, ChatGoogleGenerativeAI rejects structured output configured with method: 'jsonMode' and supports the function-calling method instead. Check the provider implementation and working integration examples when a structured-output call fails. section 8.3.2

const modelWithParser = model.withStructuredOutput(format, {
  method: 'jsonMode',
});
const result = await modelWithParser.invoke('Tell me a poem');
Error: ChatGoogleGenerativeAI only supports "functionCalling" as a method.

The failing call makes the unsupported JSON-mode configuration and resulting error concrete. section 8.3.2

How Build AI-Enhanced Web Apps covers it

How deep it goes
Works through schema-based generation, server-action wiring, UI handling, and a provider limitation without detailing JSON-mode internals.
Examples
Shows product-category requests rendered as a table and a structured-output call that fails under unsupported JSON mode.
What it assumes
Assumes an existing AI chat application and product schema, while providing a project command and API-key setup pointers.
What you can do after
Apply it via the Vercel AI SDK’s generateObject helper to validate product JSON and display it in a React interface.
How it connects
Connects structured data to JSON, Zod schemas, AI server actions, React UI state, and function calling.

Also explained in

Compare how 24 books explain structured data →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Build AI-Enhanced Web Apps. The section links point to the parts of the book it draws on.