<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>JSON输出 on AI 观察</title><link>https://ai.wujiong.cc/tags/json%E8%BE%93%E5%87%BA/</link><description>Recent content in JSON输出 on AI 观察</description><generator>Hugo</generator><language>zh-CN</language><lastBuildDate>Sun, 18 Oct 2026 18:00:00 +0800</lastBuildDate><atom:link href="https://ai.wujiong.cc/tags/json%E8%BE%93%E5%87%BA/index.xml" rel="self" type="application/rss+xml"/><item><title>让模型稳定输出 JSON 的提示写法：字段说明、枚举、空值与示例</title><link>https://ai.wujiong.cc/posts/2026-10-18-prompt-structured-json-output-guide/</link><pubDate>Sun, 18 Oct 2026 18:00:00 +0800</pubDate><guid>https://ai.wujiong.cc/posts/2026-10-18-prompt-structured-json-output-guide/</guid><description>&lt;p&gt;&lt;strong&gt;想让模型稳定输出 JSON，提示词里要把“结构、取值、缺失怎么办、除了 JSON 什么都不要”四件事写死：用字段说明表定义每个键，用枚举限制取值，明确空值约定，并给一个完整示例。&lt;/strong&gt; 即便如此，提示词只能降低出错概率，程序端的解析校验和重试仍然不能省。&lt;/p&gt;
&lt;h2 id="常见的四类出错"&gt;常见的四类出错&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;多余文字&lt;/strong&gt;：JSON 前面加一句“好的，以下是结果”，或者包在代码块里；&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;字段漂移&lt;/strong&gt;：键名时而 &lt;code&gt;name&lt;/code&gt; 时而 &lt;code&gt;title&lt;/code&gt;，或者多出你没要求的字段；&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;类型不对&lt;/strong&gt;：数字被写成带单位的字符串，布尔值写成“是/否”；&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;信息缺失时乱填&lt;/strong&gt;：原文没提的字段被编一个看似合理的值。&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;下面的写法分别针对这四类问题。&lt;/p&gt;</description></item></channel></rss>