1
我試圖創建以下列方式爲JSON模式:JSON模式要求節點
{
"$schema": "http://json-schema.org/schema#",
"title": "Layout",
"description": "The layout created by the user",
"type": "object",
"definitions": {
"stdAttribute": {
"type": "object",
"properties": {
"attributeValue": {
"type": "object"
},
"attributeName": {
"type": "string"
}
}
},
"stdItem": {
"type": "object",
"required" : ["stdAttributes"],
"properties": {
"stdType": {
"enum": [
"CONTAINER",
"TEXT",
"TEXTAREA",
"BUTTON",
"LABEL",
"IMAGE",
"MARCIMAGE",
"DATA",
"SELECT",
"TABLE"
]
},
"stdAttributes": {
"type": "array",
"items": {
"$ref": "#/definitions/stdAttribute"
}
},
"children": {
"type": "array",
"items": {
"$ref": "#/definitions/stdItem"
}
}
}
}
},
"properties": {
"layoutItem": {
"$ref": "#/definitions/stdItem"
}
}
}
我確認以下JSON反對:
{
"layoutItem": {
"stdItem": {
"stdType": "CONTAINER",
"stdAttributes": [],
"children": []
}
}
}
問題是當我運行java驗證程序時出現錯誤,因爲我按照「stdItem」的要求指定了「stdAtrributes」節點,驗證程序無法對其進行鑑別。
我試圖在屬性中定義所需的數組,但模式被取消。
如果我把 「stdAttributes」 外 「stdItem」,它的工作原理。
有誰知道我該如何定義這個要求「stdItem」?
它的工作原理!非常感謝你。 – Jeyvison