我需要帮助来构造JSON模式,其中task属性是对象类型。包含四个部门的数组类型的“开发”,“审查”,“生产”和“发行”。每个部门都有重复的任务详细信息对象,如下所示。
那么我如何为该数据定义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",
}
]
}
答案 0 :(得分:1)
从我所看到的是这样的:
{
"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"
}
}
}
}
}
}