JSON 若干约定

2018-03-08  本文已影响27人  michael_jia

JSON 是普遍使用的数据交换格式(The JSON Data Interchange Standard)。

JSON (JavaScript Object Notation)

JSON is a lightweight data-interchange format.

object&array

value

value
A value can be a string in double quotes, or a number, or true or false or null, or an object or an array. These structures can be nested.

JSON Schema

JSON Schema Validation

{
  "$schema": "http://json-schema.org/schema#",
  "title": "Product",
  "type": "object",
  "required": ["id", "name", "price"],
  "properties": {
    "id": {
      "type": "number",
      "description": "Product identifier"
    },
    "name": {
      "type": "string",
      "description": "Name of the product"
    },
    "price": {
      "type": "number",
      "minimum": 0
    },
    "tags": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "stock": {
      "type": "object",
      "properties": {
        "warehouse": {
          "type": "number"
        },
        "retail": {
          "type": "number"
        }
      }
    }
  }
}

JSON Editor Online

在线查看 json 格式文件。

上一篇 下一篇

猜你喜欢

热点阅读