JSON Objects in XML Tags

Anthropic Cookbook

Submit a prompt

Overview

Produce multiple JSON objects inside named XML tags for structured multi-object extraction.

Use cases

Prompt
Copied 0
Give me the outputs below. Put each JSON object inside the specified XML tags. No markdown fences.

1) A JSON dict with 5 items relevant to <<<topic>>> — wrap in <primary_json> tags.
2) For each item, an additional JSON object with keys "label" and "three_related_words" (array of 3 strings) — each wrapped in separate <item_json> tags.

Respond with the tagged blocks only after a one-line acknowledgment.

Can AI?

Alternatives

  • Critique a prompt for ambiguity and conflictsThis prompt checks a prompt written for an LLM for unclear wording, missing definitions, instructions that clash, and assumptions left unstated. It returns a list of issues, suggested edits to specific lines, and a rewritten version.ai agent framework
  • Grade an AI response against expert workThis prompt rates an AI answer on how well it follows its original instructions, measured against what a top human expert would deliver. It returns a letter grade from A+ to F, five reasons for the grade, a score out of 100, and how the score was reached.ai agent framework