1

JSON スキーマを書いているとします。「型」は「オブジェクト」です。オブジェクトの「プロパティ」に「説明」という名前のプロパティを含めることは合法ですか? 「説明」はJSONスキーマのキーワードなのでお尋ねします。

例:この例では、ワインのヴィンテージを表す JSON オブジェクトの単純なスキーマを示します。4 つのプロパティを指定します。3 つの必須プロパティ (ハウス、年、ブドウの品種) と、「説明」という名前の 1 つのオプション プロパティです。

{
    "$schema": "http://json-schema.org/draft-04/schema#",
    "title": "Wine vintage",
    "description": "JSON schema for wine vintages",
    "type": "object",
    "properties": {
        "house": {
            "description": "The name of the house that made the wine",
            "type": "string"
        },
        "year": {
            "description": "The year in which the wine was made",
            "type": "integer"
        },
        "varieties": {
            "description": "The grape varieties used to make the wine",
            "type": "array",
            "items": {
                "type": "string",
                "minItems": 1,
                "uniqueItems": true
            }
        }
        "description": {
            "description": "A description of the wine's taste and character; a tasting note",
            "type": "string"
        }
    },
    "required": ["house", "year", "varieties"]
}
4

2 に答える 2

3

これは合法になると思います。仕様には、スキーマ キーワードと同じオブジェクト プロパティ名の定義を具体的に禁止するものはありません。(さらに、もしそうなら、「id」、「type」、「items」などの便利で一般的な単語もプロパティ名として使用できません。)

于 2013-05-08T04:58:24.173 に答える
2

のキーに"properties"特別な意味はありません。そこには何でも使用できます: "id""description"、さらには"$ref".

スキーマ キーワードは、スキーマ オブジェクト内に直接ある場合にのみ、特別な意味を持ちます。

于 2013-07-18T12:36:16.580 に答える