{"id":55394,"date":"2025-02-19T09:23:54","date_gmt":"2025-02-19T01:23:54","guid":{"rendered":"https:\/\/fwq.ai\/blog\/55394\/"},"modified":"2025-02-19T09:23:54","modified_gmt":"2025-02-19T01:23:54","slug":"dify-%e4%b8%ad%e7%9a%84-jsonarray-object-%e6%80%8e%e4%b9%88%e7%94%a8","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/55394\/","title":{"rendered":"Dify \u4e2d\u7684 jsonarray object \u600e\u4e48\u7528"},"content":{"rendered":"<p><strong>JSONArray \u57fa\u672c\u6982\u5ff5<\/strong><\/p>\n<p><code>JSONArray<\/code>&nbsp;\u662f\u4e00\u79cd\u7528\u4e8e\u5b58\u50a8\u591a\u4e2a JSON \u5bf9\u8c61\u7684\u6570\u7ec4\u7ed3\u6784\u3002\u6bcf\u4e2a\u5143\u7d20\u90fd\u53ef\u4ee5\u662f\u4e00\u4e2a JSON \u5bf9\u8c61\u3001\u6570\u7ec4\u6216\u57fa\u672c\u6570\u636e\u7c7b\u578b\uff08\u5982\u5b57\u7b26\u4e32\u3001\u6570\u5b57\u7b49\uff09\u3002\u5728  \u4e2d\uff0c\u4f7f\u7528&nbsp;<code>JSONArray<\/code>&nbsp;\u4e3b\u8981\u6d89\u53ca\u5230 JSON \u6570\u636e\u7684\u89e3\u6790\u548c\u751f\u6210\u3002<\/p>\n<p> <\/p>\n<p>Dify \u652f\u6301\u7684\u6240\u6709\u6570\u7ec4\u7ed3\u6784\uff1aString\u3001Number\u3001Boolean\u3001Integer\u3001<strong>Object<\/strong>\u3001Array\u3001Enum\u3001anyOf<\/p>\n<p>&nbsp;<\/p>\n<p><strong>\u5173\u7cfb<\/strong><\/p>\n<ul>\n<li><strong>JSON Schema<\/strong>&nbsp;\u662f\u4e00\u79cd\u7528\u4e8e\u63cf\u8ff0\u548c\u9a8c\u8bc1 JSON \u6570\u636e\u683c\u5f0f\u7684\u89c4\u8303\u3002\u5b83\u5b9a\u4e49\u4e86 JSON \u6570\u636e\u7684\u7ed3\u6784\uff0c\u5305\u62ec\u6570\u636e\u7c7b\u578b\u3001\u5c5e\u6027\u3001\u5fc5\u9700\u5b57\u6bb5\u7b49\u3002JSON Schema \u672c\u8eab\u4e5f\u662f\u4e00\u4e2a JSON \u5bf9\u8c61\uff0c\u4f7f\u7528\u7279\u5b9a\u7684\u5173\u952e\u5b57\u6765\u63cf\u8ff0\u6570\u636e\u7684\u7ec4\u7ec7\u5f62\u5f0f\u548c\u7ea6\u675f\u6761\u4ef6\u3002<\/li>\n<li><strong>JSONArray<\/strong>&nbsp;\u662f JSON \u6570\u636e\u7684\u4e00\u79cd\u7ed3\u6784\uff0c\u8868\u793a\u4e00\u4e2a\u6709\u5e8f\u7684\u503c\u5217\u8868\u3002\u8fd9\u4e2a\u5217\u8868\u53ef\u4ee5\u5305\u542b\u591a\u4e2a JSON \u5bf9\u8c61\u3001\u6570\u7ec4\u6216\u57fa\u672c\u6570\u636e\u7c7b\u578b\u3002JSONArray \u7684\u683c\u5f0f\u662f\u7528\u4e2d\u62ec\u53f7&nbsp;<code>[]<\/code>&nbsp;\u5305\u88f9\u8d77\u6765\u7684\u3002<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p><strong>\u9a8c\u8bc1\u4e0e\u63cf\u8ff0<\/strong>\uff1aJSON Schema \u53ef\u4ee5\u7528\u6765\u9a8c\u8bc1\u5305\u542b JSONArray \u7684 JSON \u6570\u636e\u3002\u4f8b\u5982\uff0c\u53ef\u4ee5\u5728 JSON Schema \u4e2d\u5b9a\u4e49\u4e00\u4e2a\u5b57\u6bb5\u4e3a\u6570\u7ec4\u7c7b\u578b\uff0c\u5e76\u6307\u5b9a\u8be5\u6570\u7ec4\u4e2d\u7684\u6bcf\u4e2a\u5143\u7d20\u5fc5\u987b\u662f\u4e00\u4e2a\u7279\u5b9a\u683c\u5f0f\u7684 JSON \u5bf9\u8c61\u3002\u8fd9\u79cd\u65b9\u5f0f\u786e\u4fdd\u4e86\u5728\u5904\u7406\u6570\u636e\u65f6\uff0cJSONArray \u4e2d\u7684\u6bcf\u4e2a\u5143\u7d20\u90fd\u7b26\u5408\u9884\u671f\u7684\u7ed3\u6784\u548c\u7c7b\u578b\u3002<\/p>\n<p><strong>\u793a\u4f8b<\/strong>\uff1a\u5047\u8bbe\u6211\u4eec\u6709\u4e00\u4e2a JSON \u6570\u636e\u5982\u4e0b\uff1a<\/p>\n<pre>{\r\n\"users\": [\r\n{\"name\": \"Alice\", \"age\": 30},\r\n{\"name\": \"Bob\", \"age\": 25}\r\n]\r\n}<\/pre>\n<p>&nbsp;<\/p>\n<p>\u5982\u679c\u9700\u8981\u5728 Dify \u4e2d\u5b9a\u4e49\u4e00\u4e2a\u7ed3\u6784\u5316\u7684 JSON \u6570\u636e\uff0c\u53ef\u4ee5\u4f7f\u7528 JSON Schema \u6765\u63cf\u8ff0&nbsp;<code>JSONArray<\/code> \u7684\u7ed3\u6784\u3002\u5bf9\u5e94\u7684 JSON Schema \u53ef\u4ee5\u662f\uff1a<\/p>\n<pre>{\r\n\"type\": \"object\",\r\n\"properties\": {\r\n\"users\": {\r\n\"type\": \"array\",\r\n\"items\": {\r\n\"type\": \"object\",\r\n\"properties\": {\r\n\"name\": { \"type\": \"string\" },\r\n\"age\": { \"type\": \"integer\" }\r\n},\r\n\"required\": [\"name\", \"age\"]\r\n}\r\n}\r\n},\r\n\"required\": [\"users\"]\r\n}<\/pre>\n<p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0cJSON Schema \u660e\u786e\u89c4\u5b9a\u4e86&nbsp;<code>users<\/code>&nbsp;\u5b57\u6bb5\u662f\u4e00\u4e2a JSONArray\uff0c\u4e14\u5176\u4e2d\u6bcf\u4e2a\u5bf9\u8c61\u90fd\u5fc5\u987b\u5305\u542b&nbsp;<code>name<\/code>&nbsp;\u548c&nbsp;<code>age<\/code>&nbsp;\u5c5e\u6027\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>\u6240\u4ee5\u95ee\u9898\u56de\u5230\u4e86\uff1a<strong>\u5982\u4f55\u5728  \u4e2d\u4f7f\u7528 JSON Schema \u8ba9 LLM \u8f93\u51fa\u9075\u5faa\u7ed3\u6784\u5316\u683c\u5f0f\u7684\u5185\u5bb9\u3002<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p><strong>\u5728 Dify \u4e2d\u652f\u6301 JSON Schema \u529f\u80fd\u7684\u6a21\u578b<\/strong><\/p>\n<ul>\n<li><code>o1-2024-12-17<\/code>&nbsp;and later<\/li>\n<li><code>gpt-4o-mini-2024-07-18<\/code>&nbsp;and later<\/li>\n<li><code>gpt-4o-2024-08-06<\/code>&nbsp;and later<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p>\u5982\u9700\u4e86\u89e3\u66f4\u591a\u5173\u4e8e OpenAI \u7cfb\u5217\u6a21\u578b\u7684\u7ed3\u6784\u5316\u8f93\u51fa\u80fd\u529b\uff0c\u8bf7\u53c2\u8003&nbsp;\u3002<\/p>\n<p>\u6ce8\u610f\uff1ajson_schema \u548c  \u90fd\u53ef\u4ee5\u751f\u6210\u7ed3\u6784\u5316\u6570\u636e\u3002<strong>json_schema \u4ec5\u7528\u4e8e\u5bf9\u5185\u5bb9\u8fdb\u884c\u7ed3\u6784\u5316\u6570\u636e\u3002<\/strong>function calling \u5728\u8c03\u7528\u6570\u636e\u3001\u5de5\u5177\u3001\u529f\u80fd\u65f6\u5019\u5e76\u751f\u6210\u7b54\u6848\u65f6\uff0c\u66f4\u6709\u7528\u3002Dify \u4e2d\u201d\u667a\u80fd\u52a9\u7406\u201c\u5173\u8054\u5de5\u5177\uff0c\u5c31\u662f\u7528\u4e86 function calling \u7684\u65b9\u6cd5\u3002<\/p>\n<p>&nbsp;<\/p>\n<h2>\u6b63\u6587\uff1aDify \u5de5\u5177\u4e2d\u914d\u7f6e JSON Schema \u7ed3\u6784\u5316\u8f93\u51fa<\/h2>\n<p>\u4ee5\u4e0b\u662f\u6307\u5b9a LLM \u7ed3\u6784\u5316\u8f93\u51fa\u7684\u7528\u6cd5\u8def\u5f84\uff1a<\/p>\n<ol>\n<li>\u5c06 LLM \u8fde\u63a5\u5230\u7cfb\u7edf\u4e2d\u7684\u5de5\u5177\u3001\u51fd\u6570\u3001\u6570\u636e\u7b49\uff1b\u5728\u51fd\u6570\u5b9a\u4e49\u4e2d\u8bbe\u7f6e&nbsp;<code>strict: true<\/code>\uff0c\u5f53\u6253\u5f00\u5b83\u65f6\uff0c\u7ed3\u6784\u5316\u8f93\u51fa\uff08Structured-outputs\uff09\u529f\u80fd\u53ef\u786e\u4fdd LLM \u4e3a\u51fd\u6570\u8c03\u7528\u751f\u6210\u7684\u53c2\u6570\u4e0e\u4f60\u5728\u51fd\u6570\u5b9a\u4e49\u4e2d\u63d0\u4f9b\u7684 JSON \u67b6\u6784\u5b8c\u5168\u5339\u914d\u3002<\/li>\n<li>LLM \u56de\u7b54\u7528\u6237\u65f6\uff0c\u6309\u7167 JSON Schema \u4e2d\u7684\u5b9a\u4e49\uff0c\u4ee5\u7ed3\u6784\u5316\u5185\u5bb9\u683c\u5f0f\u8f93\u51fa\u3002<\/li>\n<\/ol>\n<p>\u4e0b\u6587\u5c06\u7b80\u8981\u4ecb\u7ecd\u5982\u4f55\u5728 Dify \u5f00\u542f\u5e76\u4f7f\u7528 JSON Schema \u529f\u80fd\u3002<\/p>\n<p>&nbsp;<\/p>\n<h3>1. \u5f00\u542f JSON Schema<\/h3>\n<p>\u5c06\u5e94\u7528\u4e2d\u7684 LLM \u5207\u6362\u81f3\u4e0a\u8ff0\u652f\u6301 JSON Schema \u8f93\u51fa\u7684\u6a21\u578b\uff0c\u7136\u540e\u5728\u8bbe\u7f6e\u8868\u5355\u5f00\u542f&nbsp;<code>JSON Schema<\/code>&nbsp;\u5e76\u586b\u5199 JSON Schema \u6a21\u677f\uff1b\u540c\u65f6\u5f00\u542f&nbsp;<code>response_format<\/code>&nbsp;\u680f\u5e76\u5207\u6362\u81f3&nbsp;<code>json_schema<\/code>&nbsp;\u683c\u5f0f\u3002<\/p>\n<p><img decoding=\"async\" class=\"aligncenter\" src=\"\/\/www.w3.org\/2000\/svg'%20viewBox='0%200%20768%20383'%3E%3C\/svg%3E\" title=\"Dify \u4e2d\u7684 jsonarray object \u600e\u4e48\u7528\u63d2\u56fe\" alt=\"Dify \u4e2d\u7684 jsonarray object \u600e\u4e48\u7528\u63d2\u56fe\" \/> <img decoding=\"async\" class=\"aligncenter\" src=\"https:\/\/www.aisharenet.com\/wp-content\/uploads\/2025\/01\/c8169a03a1f682b.jpg\" title=\"Dify \u4e2d\u7684 jsonarray object \u600e\u4e48\u7528\u63d2\u56fe1\" alt=\"Dify \u4e2d\u7684 jsonarray object \u600e\u4e48\u7528\u63d2\u56fe1\" \/> <\/p>\n<p>&nbsp;<\/p>\n<p>LLM \u751f\u6210\u7684\u5185\u5bb9\u652f\u6301\u4ee5\u4e0b\u683c\u5f0f\u8f93\u51fa\uff1a<\/p>\n<ul>\n<li><strong>Text:<\/strong>&nbsp;\u4ee5\u6587\u672c\u683c\u5f0f\u8f93\u51fa<\/li>\n<\/ul>\n<h3>2. \u5b9a\u4e49 JSON Schema \u6a21\u677f<\/h3>\n<p>\u4f60\u53ef\u4ee5\u53c2\u8003\u4ee5\u4e0b JSON Schema \u683c\u5f0f\u5e76\u5b9a\u4e49\u6a21\u677f\u5185\u5bb9\uff1a<\/p>\n<pre><code>{\r\n\"name\":\"template_schema\",\r\n\"description\":\"A generic template for JSON Schema\",\r\n\"strict\":true,\r\n\"schema\": {\r\n\"type\":\"object\",\r\n\"properties\": {\r\n\"field1\": {\r\n\"type\":\"string\",\r\n\"description\":\"Description of field1\"\r\n},\r\n\"field2\": {\r\n\"type\":\"number\",\r\n\"description\":\"Description of field2\"\r\n},\r\n\"field3\": {\r\n\"type\":\"array\",\r\n\"description\":\"Description of field3\",\r\n\"items\": {\r\n\"type\":\"string\"\r\n}\r\n},\r\n\"field4\": {\r\n\"type\":\"object\",\r\n\"description\":\"Description of field4\",\r\n\"properties\": {\r\n\"subfield1\": {\r\n\"type\":\"string\",\r\n\"description\":\"Description of subfield1\"\r\n}\r\n},\r\n\"required\": [\"subfield1\"],\r\n\"additionalProperties\":false\r\n}\r\n},\r\n\"required\": [\"field1\",\"field2\",\"field3\",\"field4\"],\r\n\"additionalProperties\":false\r\n}\r\n}\r\n<\/code><\/pre>\n<p>\u6b65\u9aa4\u6307\u5bfc\uff1a<\/p>\n<ol>\n<li>\u5b9a\u4e49\u57fa\u672c\u4fe1\u606f\uff1a<\/li>\n<\/ol>\n<ul>\n<li>\u8bbe\u7f6e&nbsp;<code>name<\/code>\uff1a\u4e3a\u4f60\u7684 schema \u8d77\u4e00\u4e2a\u63cf\u8ff0\u6027\u7684\u540d\u79f0\u3002<\/li>\n<li>\u6dfb\u52a0&nbsp;<code>description<\/code>\uff1a\u7b80\u8981\u8bf4\u660e schema \u7684\u7528\u9014\u3002<\/li>\n<li>\u8bbe\u7f6e&nbsp;<code>strict<\/code>: true\uff1a\u786e\u4fdd\u4e25\u683c\u6a21\u5f0f\u3002<\/li>\n<\/ul>\n<ol>\n<li>\u521b\u5efa&nbsp;<code>schema<\/code>&nbsp;\u5bf9\u8c61\uff1a<\/li>\n<\/ol>\n<ul>\n<li>\u8bbe\u7f6e&nbsp;<code>type: \"object\"<\/code>\uff1a\u6307\u5b9a\u6839\u7ea7\u522b\u4e3a\u5bf9\u8c61\u7c7b\u578b\u3002<\/li>\n<li>\u6dfb\u52a0&nbsp;<code>properties<\/code>&nbsp;\u5bf9\u8c61\uff1a\u7528\u4e8e\u5b9a\u4e49\u6240\u6709\u5b57\u6bb5\u3002<\/li>\n<\/ul>\n<ol>\n<li>\u5b9a\u4e49\u5b57\u6bb5\uff1a<\/li>\n<\/ol>\n<ul>\n<li>\u4e3a\u6bcf\u4e2a\u5b57\u6bb5\u521b\u5efa\u4e00\u4e2a\u5bf9\u8c61\uff0c\u5305\u542b&nbsp;<code>type<\/code>&nbsp;\u548c&nbsp;<code>description<\/code>\u3002<\/li>\n<li>\u5e38\u89c1\u7c7b\u578b\uff1a<code>string<\/code>,&nbsp;<code>number<\/code>,&nbsp;<code>boolean<\/code>,&nbsp;<code>array<\/code>,&nbsp;<code>object<\/code>\u3002<\/li>\n<li>\u5bf9\u4e8e\u6570\u7ec4\uff0c\u4f7f\u7528&nbsp;<code>items<\/code>&nbsp;\u5b9a\u4e49\u5143\u7d20\u7c7b\u578b\u3002<\/li>\n<li>\u5bf9\u4e8e\u5bf9\u8c61\uff0c\u9012\u5f52\u5b9a\u4e49&nbsp;<code>properties<\/code>\u3002<\/li>\n<\/ul>\n<ol>\n<li>\u8bbe\u7f6e\u7ea6\u675f\uff1a<\/li>\n<\/ol>\n<ul>\n<li>\u5728\u6bcf\u4e2a\u7ea7\u522b\u6dfb\u52a0&nbsp;<code>required<\/code>&nbsp;\u6570\u7ec4\uff0c\u5217\u51fa\u6240\u6709\u5fc5\u9700\u5b57\u6bb5\u3002<\/li>\n<li>\u5728\u6bcf\u4e2a\u5bf9\u8c61\u7ea7\u522b\u8bbe\u7f6e&nbsp;<code>additionalProperties: false<\/code>\u3002<\/li>\n<\/ul>\n<ol>\n<li>\u7279\u6b8a\u5b57\u6bb5\u5904\u7406\uff1a<\/li>\n<\/ol>\n<ul>\n<li>\u4f7f\u7528&nbsp;<code>enum<\/code>&nbsp;\u9650\u5236\u53ef\u9009\u503c\u3002<\/li>\n<li>\u4f7f\u7528&nbsp;<code>$ref<\/code>&nbsp;\u5b9e\u73b0\u9012\u5f52\u7ed3\u6784\u3002<\/li>\n<\/ul>\n<h2>\u793a\u4f8b<\/h2>\n<h3>1. \u63a8\u7406\u94fe\uff08\u5e38\u89c4\uff09<\/h3>\n<p><strong>JSON Schema \u6587\u4ef6\u793a\u4f8b<\/strong><\/p>\n<pre><code>{\r\n\"name\":\"math_reasoning\",\r\n\"description\":\"Records steps and final answer for mathematical reasoning\",\r\n\"strict\":true,\r\n\"schema\": {\r\n\"type\":\"object\",\r\n\"properties\": {\r\n\"steps\": {\r\n\"type\":\"array\",\r\n\"description\":\"Array of reasoning steps\",\r\n\"items\": {\r\n\"type\":\"object\",\r\n\"properties\": {\r\n\"explanation\": {\r\n\"type\":\"string\",\r\n\"description\":\"Explanation of the reasoning step\"\r\n},\r\n\"output\": {\r\n\"type\":\"string\",\r\n\"description\":\"Output of the reasoning step\"\r\n}\r\n},\r\n\"required\": [\"explanation\",\"output\"],\r\n\"additionalProperties\":false\r\n}\r\n},\r\n\"final_answer\": {\r\n\"type\":\"string\",\r\n\"description\":\"The final answer to the mathematical problem\"\r\n}\r\n},\r\n\"additionalProperties\":false,\r\n\"required\": [\"steps\",\"final_answer\"]\r\n}\r\n}\r\n<\/code><\/pre>\n<p><strong>\u63d0\u793a\u8bcd\u53c2\u8003<\/strong><\/p>\n<pre><code>You are a helpful math tutor. You will be provided with a math problem,\r\nand your goal will be to output a step by step solution, along with a final answer.\r\nFor each step, just provide the output as an equation use the explanation field to detail the reasoning.\r\n<\/code><\/pre>\n<h3>UI \u751f\u6210\u5668\uff08\u6839\u9012\u5f52\u6a21\u5f0f\uff09<\/h3>\n<pre><code>{\r\n\"name\":\"ui\",\r\n\"description\":\"Dynamically generated UI\",\r\n\"strict\":true,\r\n\"schema\": {\r\n\"type\":\"object\",\r\n\"properties\": {\r\n\"type\": {\r\n\"type\":\"string\",\r\n\"description\":\"The type of the UI component\",\r\n\"enum\": [\"div\",\"button\",\"header\",\"section\",\"field\",\"form\"]\r\n},\r\n\"label\": {\r\n\"type\":\"string\",\r\n\"description\":\"The label of the UI component, used for buttons or form fields\"\r\n},\r\n\"children\": {\r\n\"type\":\"array\",\r\n\"description\":\"Nested UI components\",\r\n\"items\": {\r\n\"$ref\":\"#\"\r\n}\r\n},\r\n\"attributes\": {\r\n\"type\":\"array\",\r\n\"description\":\"Arbitrary attributes for the UI component, suitable for any element\",\r\n\"items\": {\r\n\"type\":\"object\",\r\n\"properties\": {\r\n\"name\": {\r\n\"type\":\"string\",\r\n\"description\":\"The name of the attribute, for example onClick or className\"\r\n},\r\n\"value\": {\r\n\"type\":\"string\",\r\n\"description\":\"The value of the attribute\"\r\n}\r\n},\r\n\"additionalProperties\":false,\r\n\"required\": [\"name\",\"value\"]\r\n}\r\n}\r\n},\r\n\"required\": [\"type\",\"label\",\"children\",\"attributes\"],\r\n\"additionalProperties\":false\r\n}\r\n}\r\n<\/code><\/pre>\n<p><strong>\u63d0\u793a\u8bcd\u53c2\u8003\uff1a<\/strong><\/p>\n<pre><code>You are a UI generator AI. Convert the user input into a UI.\r\n<\/code><\/pre>\n<p><strong>\u6548\u679c\u793a\u4f8b\uff1a<\/strong><\/p>\n<p><img decoding=\"async\" class=\"aligncenter\" src=\"\/\/www.w3.org\/2000\/svg'%20viewBox='0%200%20626%20524'%3E%3C\/svg%3E\" title=\"Dify \u4e2d\u7684 jsonarray object \u600e\u4e48\u7528\u63d2\u56fe2\" alt=\"Dify \u4e2d\u7684 jsonarray object \u600e\u4e48\u7528\u63d2\u56fe2\" \/> <img decoding=\"async\" class=\"aligncenter\" src=\"https:\/\/www.aisharenet.com\/wp-content\/uploads\/2025\/01\/63dfdd1f2797962.jpg\" title=\"Dify \u4e2d\u7684 jsonarray object \u600e\u4e48\u7528\u63d2\u56fe3\" alt=\"Dify \u4e2d\u7684 jsonarray object \u600e\u4e48\u7528\u63d2\u56fe3\" \/> <\/p>\n<p>&nbsp;<\/p>\n<h2>\u63d0\u793a<\/h2>\n<ul>\n<li>\u8bf7\u786e\u4fdd\u5e94\u7528\u63d0\u793a\u8bcd\u5185\u5305\u542b\u5982\u4f55\u5904\u7406\u7528\u6237\u8f93\u5165\u65e0\u6cd5\u4ea7\u751f\u6709\u6548\u54cd\u5e94\u7684\u60c5\u51b5\u8bf4\u660e\u3002<\/li>\n<li>\u6a21\u578b\u5c06\u59cb\u7ec8\u5c1d\u8bd5\u9075\u5faa\u63d0\u4f9b\u7684\u6a21\u5f0f\uff0c\u5982\u679c\u8f93\u5165\u7684\u5185\u5bb9\u4e0e\u6307\u5b9a\u7684\u6a21\u5f0f\u5b8c\u5168\u65e0\u5173\uff0c\u5219\u53ef\u80fd\u4f1a\u5bfc\u81f4 LLM \u4ea7\u751f\u5e7b\u89c9\u3002<\/li>\n<li>\u5982\u679c LLM \u68c0\u6d4b\u5230\u8f93\u5165\u4e0e\u4efb\u52a1\u4e0d\u517c\u5bb9\uff0c\u4f60\u53ef\u4ee5\u5728\u63d0\u793a\u4e2d\u5305\u542b\u8bed\u8a00\uff0c\u4ee5\u6307\u5b9a\u8fd4\u56de\u7a7a\u53c2\u6570\u6216\u7279\u5b9a\u53e5\u5b50\u3002<\/li>\n<li>\u6240\u6709\u5b57\u6bb5\u5fc5\u987b\u4e3a&nbsp;<code>required<\/code>\uff0c\u8be6\u60c5\u8bf7\u53c2\u8003\u3002<\/li>\n<li>&nbsp;\u5fc5\u987b\u59cb\u7ec8\u5728\u5bf9\u8c61\u4e2d\u8bbe\u7f6e<\/li>\n<li>\u6a21\u5f0f\u7684\u6839\u7ea7\u522b\u5bf9\u8c61\u5fc5\u987b\u662f\u4e00\u4e2a\u5bf9\u8c61<\/li>\n<li><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>JSONArray \u57fa\u672c\u6982\u5ff5 JSONArray&nbsp;\u662f\u4e00\u79cd\u7528\u4e8e\u5b58\u50a8\u591a\u4e2a JSON \u5bf9\u8c61\u7684\u6570\u7ec4\u7ed3\u6784\u3002\u6bcf\u4e2a\u5143\u7d20\u90fd\u53ef\u4ee5\u662f\u4e00\u4e2a JSON \u5bf9\u8c61\u3001\u6570\u7ec4\u6216\u57fa\u672c\u6570\u636e\u7c7b\u578b\uff08\u5982\u5b57\u7b26\u4e32\u3001\u6570\u5b57\u7b49\uff09\u3002\u5728 \u4e2d\uff0c\u4f7f\u7528&nbsp;JSONArray&nbsp;\u4e3b\u8981\u6d89\u53ca\u5230 JSON \u6570\u636e\u7684\u89e3\u6790\u548c\u751f\u6210\u3002 Dify \u652f\u6301\u7684\u6240\u6709\u6570\u7ec4\u7ed3\u6784\uff1aString\u3001Number\u3001Boolean\u3001Integer\u3001Object\u3001Array\u3001Enum\u3001anyOf &nbsp; \u5173\u7cfb JSON Schema&nbsp;\u662f\u4e00\u79cd\u7528\u4e8e\u63cf\u8ff0\u548c\u9a8c\u8bc1 JSON \u6570\u636e\u683c\u5f0f\u7684\u89c4\u8303\u3002\u5b83\u5b9a\u4e49\u4e86 JSON \u6570\u636e\u7684\u7ed3\u6784\uff0c\u5305\u62ec\u6570\u636e\u7c7b\u578b\u3001\u5c5e\u6027\u3001\u5fc5\u9700\u5b57\u6bb5\u7b49\u3002JSON Schema \u672c\u8eab\u4e5f\u662f\u4e00\u4e2a JSON \u5bf9\u8c61\uff0c\u4f7f\u7528\u7279\u5b9a\u7684\u5173\u952e\u5b57\u6765\u63cf\u8ff0\u6570\u636e\u7684\u7ec4\u7ec7\u5f62\u5f0f\u548c\u7ea6\u675f\u6761\u4ef6\u3002 JSONArray&nbsp;\u662f JSON \u6570\u636e\u7684\u4e00\u79cd\u7ed3\u6784\uff0c\u8868\u793a\u4e00\u4e2a\u6709\u5e8f\u7684\u503c\u5217\u8868\u3002\u8fd9\u4e2a\u5217\u8868\u53ef\u4ee5\u5305\u542b\u591a\u4e2a JSON \u5bf9\u8c61\u3001\u6570\u7ec4\u6216\u57fa\u672c\u6570\u636e\u7c7b\u578b\u3002JSONArray \u7684\u683c\u5f0f\u662f\u7528\u4e2d\u62ec\u53f7&nbsp;[]&nbsp;\u5305\u88f9\u8d77\u6765\u7684\u3002 &nbsp; \u9a8c\u8bc1\u4e0e\u63cf\u8ff0\uff1aJSON Schema \u53ef\u4ee5\u7528\u6765\u9a8c\u8bc1\u5305\u542b JSONArray \u7684 JSON \u6570\u636e\u3002\u4f8b\u5982\uff0c\u53ef\u4ee5\u5728 JSON Schema \u4e2d\u5b9a\u4e49\u4e00\u4e2a\u5b57\u6bb5\u4e3a\u6570\u7ec4\u7c7b\u578b\uff0c\u5e76\u6307\u5b9a\u8be5\u6570\u7ec4\u4e2d\u7684\u6bcf\u4e2a\u5143\u7d20\u5fc5\u987b\u662f\u4e00\u4e2a\u7279\u5b9a\u683c\u5f0f\u7684 JSON \u5bf9\u8c61\u3002\u8fd9\u79cd\u65b9\u5f0f\u786e\u4fdd\u4e86\u5728\u5904\u7406\u6570\u636e\u65f6\uff0cJSONArray \u4e2d\u7684\u6bcf\u4e2a\u5143\u7d20\u90fd\u7b26\u5408\u9884\u671f\u7684\u7ed3\u6784\u548c\u7c7b\u578b\u3002 \u793a\u4f8b\uff1a\u5047\u8bbe\u6211\u4eec\u6709\u4e00\u4e2a JSON \u6570\u636e\u5982\u4e0b\uff1a { &#8220;users&#8221;: [ {&#8220;name&#8221;: &#8220;Alice&#8221;, &#8220;age&#8221;: 30}, {&#8220;name&#8221;: [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13],"tags":[],"class_list":["post-55394","post","type-post","status-publish","format-standard","hentry","category-ai"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/55394","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=55394"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/55394\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=55394"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=55394"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=55394"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}