0
我嘗試爲我的數據編寫json模式。這些數據看起來是這樣:Json-Schema:同一類型的多個元素
{
"gold": [
{
"id": "goldOne",
"name": "firstGold",
"title": "Gold 1 earned"
},
{
"id": "goldTwo",
"name": "secondGold",
"title": "Gold 2 earned"
}
],
"silver": [
{
"id": "silberOne",
"name": "firstSilver",
"title": "Silver!"
}
],
"bronze": [
{
"id": "bronzeOne",
"name": "firstBronze",
"title": "Bronze!"
}
]
}
我已經創建的模式爲「金」 - 陣列:
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title" : "trophy descriptions",
"type": "object",
"properties": {
gold: {
"description": "gold trophies",
"type":"array",
"items": {
"type": "object",
"properties": {
"id": {
"type": "string",
"description": "unique identifier"
},
"name": {
"type": "string",
"description": "label of trophy"
},
"title": {
"type": "string",
"description": "description of trophy"
}
}
}
}
}
}
因爲「銀」和「銅」 -arrays包含完全相同的元素鍵入爲「黃金」我不知道是否我必須三次寫下相同的東西,或者我可以參考單個描述?