讓 AI 輸出更穩、更準?試試 JSON Prompt!
處理 AI 就像坐過山車。
有一天,你讓它給個快速提示清單,結果得到一堆整齊的 bullet points。
下一天呢?
一堆亂七八糟的文字,整理起來費老鼻子勁了。
真是讓人抓狂。
后來我發現了 JSON 提示,感覺就像終于讓 AI 聽懂了我的話。
下面是我對 JSON 提示的看法,講得簡單點,還帶點代碼。
啥是 JSON?
JSON 全稱是 JavaScript Object Notation。別被名字嚇到——它就是一種帶清晰標簽的組織信息的方式。想象一下,就像一份購物清單,每件東西都有個標簽:
{"fruit": "apples","quantity": 5,"store": "local market"}
為啥 AI 愛這個?因為它們在網站和 app 上被一大堆 JSON 數據訓練過。這就像是說它們的母語。用 JSON 提示,你就是在清清楚楚地告訴 AI 你想要啥,它搞砸的概率低多了。
普通提示就是一團亂
前段時間,我為了一個項目,拼了命想讓 AI 總結客戶郵件。我說“總結這封郵件”,結果一次給我一段話,一次給個列表,有時候就一句。完全沒譜。后來我試了 JSON 提示:
{
"task": "summarize_email",
"email": "Love the app, but it keeps crashing.",
"output": "list",
"max_points": 3
}結果立馬得到一個干凈的列表:
[
"App is great",
"Crashes often",
"User likes it overall"
]再也沒亂七八糟的輸出。我直接把這個塞進我的 spreadsheet,搞定,繼續干別的。
JSON 提示咋工作
JSON 超簡單。分解一下:
? Labels:你的標簽,永遠帶引號(像 "task")。
? Info:你想要的內容,像是文字或數字。
? Curly braces {}:把所有東西裝一起,像個盒子。
? Square brackets []:用來列清單,像 checklist。
? Commas ,:把東西分開。
比如你想要給高中生一些學習建議。普通提示像“給學生學習建議”太模糊——學生可能是任何人。用 JSON,你可以很具體:
{
"task": "study_tips",
"who_for": "high school kids",
"how_many": 4,
"vibe": "upbeat",
"output": "list"
}結果是:
[
"Make a study plan and stick to it.",
"Find a quiet corner to focus.",
"Try flashcards for quick reviews.",
"Take a break when you’re tired."
]就像給 AI 一個清晰的指令單,沒啥猜謎空間。
確保 AI 不跑偏
有些 AI 平臺可以讓你用特殊設置鎖定輸出格式。就像跟 AI 說:“照這個格式來,不然別干!”比如:
? OpenAI:可以用 response_format 設置嚴格結構。
? Anthropic:他們有個 tool-calling 功能也能干這事。
? Google:直接把輸出設成 application/json。
這讓你的提示從“還行”變成“次次都靠譜”。
真實案例:省時處理郵件
上個月,我被客戶郵件淹沒了。我得提取名字、公司和他們抱怨啥。JSON 提示救了我一命。我用的是:
{
"task": "pull_info",
"email": "Hi, I’m Mike from CoolTech. Our app won’t load, and it’s a big deal!",
"output": {
"name": "string",
"company": "string",
"problem": "string",
"urgency": ["low", "medium", "high"]
}
}結果:
{"name": "Mike","company": "CoolTech","problem": "app not loading","urgency": "high"}
這花了兩秒鐘。手動弄?每封郵件至少幾分鐘。一天 30 封郵件,我省了好幾個小時。
三個好用的 JSON 模板
JSON 提示在幾個關鍵任務上特別好使:提取數據、創建內容、分析東西。我是這么設置的。
1. 提取數據
用來從郵件或評論里挖信息:
"task": "pull_info",
"text": "Put your text here",
"output": {
"field1": "string",
"field2": "number",
"field3": ["option1", "option2"]
}
}2. 創建內容
用來寫東西,比如社交媒體帖子:
"task": "write_post",
"type": "tweet",
"who_for": "small businesses",
"vibe": "fun",
"points": ["save time", "grow sales"],
"words": 100
}可能會得到:
{
"post": "Small biz folks! Save time and grow sales with these easy tips...",
"word_count": 95
}3. 分析東西
用來分解大概念,比如公司概況:
{
"task": "analyze",
"company": "Nike",
"output": {
"strong_points": ["string"],
"weak_points": ["string"],
"stock_tip": ["buy", "sell", "hold"],
"confidence": "number"
}
}輸出:
{
"strong_points": ["Cool brand", "Big market share"],
"weak_points": ["Expensive products", "Competition"],
"stock_tip": "buy",
"confidence": 0.8
}這直接就能放進報告或 dashboard,不用額外折騰。
嵌套:整齊但有點棘手
JSON 可以一層套一層,像盒子里裝盒子。比如我在計劃一個項目:
{
"task": "plan_project",
"project": "New Website",
"output": {
"stages": [
{
"name": "string",
"tasks": [
{
"task": "string",
"days": "number",
"priority": ["low", "medium", "high"]
}
]
}
]
}
}結果:
{
"stages": [
{
"name": "Design",
"tasks": [
{
"task": "Sketch layout",
"days": 7,
"priority": "high"
},
{
"task": "Pick colors",
"days": 3,
"priority": "medium"
}
]
}
]
}但別嵌套得太瘋。超過幾層,AI 可能會迷路,就像我試著照復雜菜譜做飯一樣。
讓 AI 老實聽話
你可以用 schema 讓 AI 嚴格按格式來。我常用這個:
{
"task": "check_mood",
"text": "This app is awesome!",
"output": {
"mood": ["happy", "sad", "neutral"],
"confidence": "number"
}
}輸出:
{
"mood": "happy",
"confidence": 0.9
}AI 必須照這規則來——沒得商量。就像跟小孩說:“就一塊餅干,沒得挑。”
處理小故障
有時候會出點問題——網絡斷了,或者 AI 太“創意”了。我的辦法是:
1. 用清晰格式發 JSON 提示。
2. 檢查輸出有沒有毛病。
3. 如果不靠譜,試三次,設置 temperature=0(這讓 AI 更專注)。
4. 還是不行,我就自己瞅一眼。
為啥 Temperature 重要
Temperature 就像 AI 的創意旋鈕。temperature=1 時,它可能會改詞或格式。temperature=0 時,超級穩定。我用 JSON 提示時,總是設 temperature=0,免得意外。
我的郵件處理招
我現在處理郵件是這樣的:
1. 郵件進來。
2. JSON 提示抓關鍵信息。
3. 檢查輸出行不行。
4. 如果沒問題,直接進 database。
5. 不行就再試幾次。
6. 最壞情況,我自己看一眼。
這招能自動搞定大部分郵件,把我的工作量從幾小時砍到幾分鐘。
為啥我愛 JSON 提示
JSON 提示省了我老多時間。不管是整理郵件還是做報告,結構化的輸出讓我不用再收拾 AI 的爛攤子。就像有個超級有條理的助理,每次都干得漂漂亮亮。
試試看吧
想試試 JSON 提示?這個簡單好玩:
{
"task": "get_quote",
"theme": "hope",
"length": "short",
"output": {
"quote": "string",
"author": "string"
}
}可能會得到:
{
"quote": "Keep going, you’ve got this.",
"author": "Nobody Famous"
}JSON 提示就像給 AI 一個清晰的待辦清單。可以試試看這種方式來管理自己行的提示詞工程,感覺會比較有用。






























