2013-05-08 1 views
1

JSON 스키마를 작성한다고 가정 해 보겠습니다. "유형"은 "객체"입니다. "description"이라는 속성을 객체의 "속성"에 포함시키는 것이 합법적입니까? "설명"은 JSON 스키마의 키워드이기 때문에 묻습니다."설명"은 JSON 스키마의 개체에 유효한 "속성"입니까?

예 :이 예제에서는 와인 빈티지를 나타내는 JSON 객체에 대한 간단한 스키마를 보여줍니다. 나는 네 가지 속성, 즉 3 가지 필수 속성 (하우스, 연도 및 포도 품종)과 하나의 선택적 속성 인 "설명"을 지정합니다.

{ 
    "$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"] 
} 

답변

2

나는 이것이 합법적이라고 생각합니다. 나는 spec에서 스키마 키워드와 동일한 개체 속성 이름을 정의하는 것을 특별히 금지하는 것을 보지 못했습니다. (그 외에도 "id", "type"및 "items"와 같은 유용하고 일반적인 단어는 속성 이름으로 사용할 수 없습니다.)

1

"properties"의 키는 특별한 의미가 없습니다. 그 안에는 "id", "description", 심지어 "$ref"과 같은 것을 사용할 수 있습니다.

스키마 개체 내에서 이 바로 인 경우 스키마 키워드는 특별한 의미가 있습니다.