JSON模式draft4 VS JSON模式draft3

use*_*996 18 json jsonschema

模式草案4中存在哪些不在IETF生成的JSON模式草案3中的功能?

hun*_*erc 29

从更改日志中:

新关键字

  • anyOf(匹配模式数组中的至少一个模式),
  • allOf(匹配模式数组中的所有模式),
  • oneOf(与架构数组中的一个架构完全匹配),
  • 不(不匹配架构),
  • multipleOf(替换divisibleBy),
  • minProperties和maxProperties(对象实例中的最小和最大成员数),
  • 定义(内联子模式的标准化容器).

删除:

  • 不允许
  • 扩展
  • divisbleBy

功能改变:

类型

  • 当值是数组时,不再允许模式作为元素.此外,该数组必须至少有一个元素.

之前


{
    "type": [ "string", { "other": "schema" } ]
}
Run Code Online (Sandbox Code Playgroud)

现在


{
   "anyOf": [
       { "type": "string" },
       { "other": "schema" }
    ]
}
Run Code Online (Sandbox Code Playgroud)

需要

  • 之前,它是属性中子模式的属性.它现在是扮演相同角色的第一级关键字,并且有一个字符串数组作为参数.

之前


{
    "properties": {
        "p": {
            "type": "string",
            "required": true
        },
        "q": {
            "type": "string",
            "required": true
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

现在


{
    "properties": {
        "p": { "type": "string" },
        "q": { "type": "string" }
    },
    "required": [ "p", "q" ]
}
Run Code Online (Sandbox Code Playgroud)

依赖

  • 不再允许属性依赖项中的单个字符串,仅允许数组

之前


{
    "dependencies": { "a": "b" }
}
Run Code Online (Sandbox Code Playgroud)

现在


{
    "dependencies": { "a": [ "b" ] }
}
Run Code Online (Sandbox Code Playgroud)


Eze*_*lin 6

如果您对深度潜水感兴趣,可以查看IETF网站上两个草稿之间的差异.

但是,如果您正在寻找更简单的更改摘要,Geraint Luff和Francis Galiegue在项目的github wiki上创建了一个更新日志页面,其中列出了更改,添加和删除.