2013-06-21 25 views
1

我不確定JSON Schema「description」字段的用途是什麼。該領域是否可以作爲評論的空間?該字段是否用作ID?JSON模式中「description」字段的用途是什麼?

{ 
    "id": "http://www.noodle.org/entry-schema#", 
    "schema": "http://json-schema.org/draft-04/schema#", 
    "description": "schema for online courses", 
    "type": "object", 
    "properties": { 
     "institution": { 
      "type": "object", 
      "$ref" : "#/definitions/institution" 
     }, 
     "person": { 
      "type": "object", 
      "items": { 
       "type": "object", 
       "$ref": "#/definitions/person" 
      } 
    "definitions": {   
     "institution": { 
      "description": "University", 
      "type": "object", 
      "properties": { 
       "name":{"type":"string"}, 
       "url":{ 
        "format": "uri", 
        "type": "string" 
       }, 
       "descriptionofinstitution":{"type":"string"}, 
       "location": { 
        "description": "location", 
       "type": "string", 
       "required": true 
       } 
     } 

}

+0

你可以發表一個例子嗎? –

回答

0

在JSON一切數據,所以沒有什麼特別的在一個名爲description領域,它只是一個字段作爲idtype是。

當然description中可能有特殊的含義在你的域名,但就JSON關注只不過是另一種性質。

1

這可能是一些額外的解釋,爲了增強關於具體條目的知識,如果id不夠。當然,它不會影響代碼本身的行爲

14

根據JSON模式規範(http://json-schema.org/latest/json-schema-validation.html#anchor98),「描述」(和「標題」)字段的目的是裝飾用戶界面並提供有關此用戶界面生成的數據的信息。標題最好是簡短的,而描述將提供關於該模式描述的實例的目的的解釋。

+0

它也可以非常方便地直接從json-schema文件生成文檔! –

+5

這是正確的答案,但我無法改變接受的答案。 –

相關問題