You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何定义含指定4个部门任务结构的合规JSON Schema?

JSON Schema for Task Department Structure

Hey there! Let's build the JSON Schema you're looking for, aligned perfectly with your requirements and sample data. First, quick note: I spotted a typo in your sample (taks should be task)—I'll make sure the schema uses the correct property name.

Key Requirements We'll Enforce

  • The root object must include a task property of type object
  • The task object can only contain four required array properties: development, review, production, distribution (no extra properties allowed)
  • Each department array holds identical task detail objects, with all the fields from your sample

Complete JSON Schema

{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "required": ["task"],
  "properties": {
    "task": {
      "type": "object",
      "required": ["development", "review", "production", "distribution"],
      "additionalProperties": false,
      "properties": {
        "development": {
          "type": "array",
          "items": {
            "type": "object",
            "required": ["description", "assigned_to", "start_date", "end_date", "status", "priority"],
            "properties": {
              "description": { "type": "string" },
              "assigned_to": { "type": "string" },
              "start_date": { "type": "string" },
              "end_date": { "type": "string" },
              "status": {
                "type": "string",
                "enum": ["wip", "complete", "OnHold"]
              },
              "priority": {
                "type": "string",
                "enum": ["normal", "high", "low"]
              }
            },
            "additionalProperties": false
          }
        },
        "review": {
          "$ref": "#/properties/task/properties/development"
        },
        "production": {
          "$ref": "#/properties/task/properties/development"
        },
        "distribution": {
          "$ref": "#/properties/task/properties/development"
        }
      }
    }
  },
  "additionalProperties": false
}

Schema Breakdown

Let's walk through what this does:

  • Root Level: Ensures only the task property exists at the root (via additionalProperties: false) and that it's required.
  • Task Object: Uses additionalProperties: false to strictly limit the allowed properties to the four departments—no extra ones can be added. All four departments are marked as required, so they'll always be present (even if their arrays are empty).
  • Task Detail Objects:
    • All fields from your sample are marked as required, so every task must have them.
    • I added enum values for status and priority based on your sample data to restrict valid inputs to the values you're using. If you need to allow more values later, you can just update the enum lists.
    • additionalProperties: false on the task object ensures no extra fields can be added to individual tasks.
  • Reusable Task Array: Instead of repeating the task object schema for each department, we use $ref to point to the development schema—this keeps the code DRY and makes updates easier.

This schema will validate your sample data (once you fix the taks typo) and enforce all your requirements strictly.

内容的提问来源于stack exchange,提问作者Ruchit

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.14 08:05:35