美文网首页
JSON 若干约定

JSON 若干约定

作者: michael_jia | 来源:发表于2018-03-08 20:42 被阅读27次

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.
  • null
  • boolean
    A "true" or "false" value.
  • object
    An object is an unordered set of name/value pairs.
  • array
    An array is an ordered collection of values. An array begins with [ (left bracket) and ends with ] (right bracket). Values are separated by , (comma).
  • number
    An arbitrary-precision, base-10 decimal number value.
    "integer" matches any number with a zero fractional part.
  • string
    a sequence of zero or more Unicode characters. Strings are delimited with double-quotation marks and support a backslash escaping syntax.

JSON Schema

  • describes your existing data format.
  • clear, human- and machine-readable documentation.
  • complete structural validation, useful for:
    1)automated testing.
    2)validating client-submitted data.

JSON Schema Validation

  • JSON Schema Validation: A Vocabulary for Structural Validation of JSON.
  • Latest JSON Schema Validation
    JSON Schema Validation defines the validation keywords of JSON Schema.
  • Validation Keywords
    比如:required、properties 就是 Validation Keywords for Objects.
  • JSON Schema Example
{
  "$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 格式文件。

相关文章

  • JSON 若干约定

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

  • 近期常用

    bash 脚本要点 bash testing vim:你的不二选择 JSON 若干约定 Linux 常用命令 Bu...

  • 后端开发和部署的若干约定

    上周新人 Los 加入;对 Yii 熟悉的对 Laravel 不熟悉,反之亦然;这里记录一下代码设计的约定;关于 ...

  • Ajax数据请求

    ajax数据获取 一.PC和服务器约定 1.数据格式 JSON:JavaScript Object Notatio...

  • iOS比较好用的第三方框架

    1.Model ①MJExtension- 用于json转model,转换效率高,使用简单,只需前后台约定好格式,...

  • 微信小程序配置标签栏

    配置tabBar:对若干一级页面的入口链接。在app.json中配置tabBar属性。 配置关于和推荐电影 此时前...

  • AFN使用Restful接口

    使用Restful接口通常约定使用JSON数据格式进行请求响应,发出的请求是只需将Header中的"Content...

  • BitRabbit Zendesk API

    0.约定 下述接口的任何结构中,url表示这个接口的真实JSON地址,html_url表示网页地址,抓取html_...

  • json web token 理论与实战

    理论 概念 JSON Web Token(JWT)是一个非常轻巧的规范(约定好的这么做)。这个规范允许我们使用 J...

  • 若干诗意若干得

    如果语文是个美人,想这样描摩她:“腰若流纨素,耳著明月珰。纤纤作细步,精妙世无双”。直入人心,优雅灵动。 ...

网友评论

      本文标题:JSON 若干约定

      本文链接:https://www.haomeiwen.com/subject/vbkpxftx.html