Массив JSON-схемы повторяющегося объекта - PullRequest
0 голосов
/ 19 сентября 2019

Мне нужна помощь для создания схемы JSON, где свойство задачи имеет тип объекта.Содержит четыре отдела «разработка», «обзор», «производство» и «распространение» типа массива.И у каждого отдела есть повторяющийся объект сведений о задаче, как показано ниже.

Так, как я могу определить схему JSON для этих данных?

Примечание: отдел не должен содержать данные другого типа

"taks": {
    "development":[
        {
            "description": "",
            "assigned_to":"Cortney.Brown",
            "start_date": "8-28-2019",
            "end_date": "9-15-2019",
            "status":"wip",
            "priority":"normal",
        },
        {
            "description": "",
            "assigned_to":"Renfred.Rogers",
            "start_date": "8-29-2019",
            "end_date": "9-10-2019",
            "status":"complete",
            "priority":"high",
        }
    ],
    "review": [
        {
            "description": "",
            "assigned_to":"Herring.Myers",
            "start_date": "8-30-2019",
            "end_date": "9-5-2019",
            "status":"OnHold",
            "priority":"low",
        },
        {
            "description": "",
            "assigned_to":"Dimos.Gomez",
            "start_date": "9-2-2019",
            "end_date": "9-12-2019",
            "status":"wip",
            "priority":"normal",
        }
    ],
    "production": [
        {
            "description": "",
            "assigned_to":"Ridge.Lopez",
            "start_date": "9-5-2019",
            "end_date": "9-15-2019",
            "status":"wip",
            "priority":"normal",
        },
        {
            "description": "",
            "assigned_to":"Keyon.Hill",
            "start_date": "9-7-2019",
            "end_date": "9-13-2019",
            "status":"OnHold",
            "priority":"low",
        },
        {
            "description": "",
            "assigned_to":"Bennett.Sanchez",
            "start_date": "9-10-2019",
            "end_date": "9-20-2019",
            "status":"complete",
            "priority":"low",
        }
    ],
    "distribution": [
        {
            "description": "",
            "assigned_to":"Kemen.Adams",
            "start_date": "9-12-2019",
            "end_date": "9-20-2019",
            "status":"complete",
            "priority":"high",
        }
    ]
}

1 Ответ

1 голос
/ 19 сентября 2019

Из того, что я вижу, примерно так:

{
  "type": "object",
  "$schema": "http://json-schema.org/draft-06/schema#",
  "description": "JSON schema generated with JSONBuddy https://www.json-buddy.com",
  "properties": {
    "taks": {
      "$ref": "#/definitions/taks"
    }
  },
  "definitions": {
    "an_item": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "assigned_to": {
          "type": "string"
        },
        "description": {
          "type": "string"
        },
        "end_date": {
          "type": "string"
        },
        "priority": {
          "type": "string"
        },
        "start_date": {
          "type": "string"
        },
        "status": {
          "type": "string"
        }
      }
    },
    "taks": {
      "type": "object",
      "properties": {
        "development": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/an_item"
          }
        },
        "distribution": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/an_item"
          }
        },
        "production": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/an_item"
          }
        },
        "review": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/an_item"
          }
        }
      }
    }
  }
}
...