Upgrade to Pro — share decks privately, control downloads, hide ads and more …

JSON Schema and JSONNanny

JSON Schema and JSONNanny

Yulin Ding

July 25, 2013
Tweet

Other Decks in Technology

Transcript

  1. 重复定义的成本 { “name” : “商品名称”, “price” : “200”, “tmall” :

    true } { “title” : “商品名称”, “price” : 200, “isTmall” : 1 }
  2. JSON Schema历史 • 2009.12.5 draft 01 • 2010.3.23 draft 02

    • 2010.11.22 draft 03 • 2013.1.31 draft 04
  3. type “user” : { “type” : “string” } “user” :

    { “type” : [“null”, “object”] } { “user” : null } { “user” : {“foo” : “bar”} }
  4. title, description “user” : { “type” : “string”, “title” :

    “⽤用户名称”, “description” : “更详细的描述” } “user” : “sodabiscuit”
  5. disallow “user” : { “disallow” : null } { “user”

    : null } { “user” : {“foo” : “bar”} }
  6. properties { “type”: “object”, “properties” : { “price” : {

    “type” : “number” } } } { “price” : 200 }
  7. additionalProperties { “type”: “object”, “properties” : { “price” : {

    “type” : “number” } }, “additionalProperties” : { “type” : “number” } } { “price” : 200, “discount” : 20 }
  8. required { “type”: “object”, “properties” : { “price” : {

    “type” : “number”, “required” : true } } } { “price” : 200 }
  9. items “product_id_list” : { “type” : “array”, “items” : {

    “type” : “string” } } { “product_id_list” : [“9ef84a26d”, “ac78dcmd2”] }
  10. additionalItems { “type”: “array”, “items” : [ { “type” :

    “boolean” }, { “type” : “number” } ] “additionalItems” : { “type” : “string” } } [true, 1, “foo”, “bar”]
  11. minItems,maxItems,uniqueItems “product_id_list” : { “type” : “array”, “items” : {

    “type” : “string” }, “minItems” : 2, “uniqueItems” : true } { “product_id_list” : [“foo”, “bar”] }
  12. exclusiveMinimum,exclusiveMaxi mum “price” : { “type” : “number”, “minimum” :

    “1”, “maximum” : “20”, “exclusiveMinimum” : true } { “price” : 2 }
  13. extends { “item” : { “type”: “object”, “properties” : {

    “price” : { “type” : “number” } } } } { “item” : { “type”: “object”, “properties” : { “discount” : { “type” : “number” } }, “extends” : #/item } }