Link to the specification: http://json-schema.org/latest/json-schema-validation.html#anchor64

Section 5.4.4.2 states:

Successful validation of an object instance against these three keywords depends on the value of "additionalProperties": if its value is boolean true or a schema, validation succeeds; ...

Section 5.4.4.3 states:

If "additionalProperties" is absent, it may be considered present with an empty schema as a value.

好的,如果没有"additionalProperties",它将被视为存在一个空模式.如果它是一个模式(任何类型),那么不管其他考虑因素如何,对象都会成功验证.

But this is contradicted by the assertion in section 5.4.4.5, "Example", that the given instance fails to validate against the given schema (which doesn't specify anything for "additionalProperties").

Can someone explain where and in what way I'm misinterpreting the specification?

推荐答案

You have found an error in the spec, so your not actually misinterpreting something.

There is an updated version (from two days later) of the internet draft on the IETF website, where this example is different.

see: https://datatracker.ietf.org/doc/html/draft-fge-json-schema-validation-00#page-13

由于该文件是一份互联网草稿,http://datatracker.ietf.org/上的版本很可能是正确的版本.

Status of This Memo

This Internet-Draft is submitted in full conformance with the
provisions of BCP 78 and BCP 79.

Internet-Drafts are working documents of the Internet Engineering
Task Force (IETF)
. Note that other groups may also distribute
working documents as Internet-Drafts. The list of current Internet-
Drafts is at http://datatracker.ietf.org/drafts/current/.

Internet-Drafts are working documents of the Internet Engineering
Task Force (IETF).

此外,这两个版本有不同的日期和有效期:

  • version you link - written: January 30, 2013 and Expires: August 3, 2013.
  • version on ietf - written on: February 1, 2013 and Expires: August 5, 2013

On the IETF version:

This schema will be used as an example:

   {
       "properties": {
           "p1": {}
       },
       "patternProperties": {
           "p": {},
           "[0-9]": {}
       },
       "additionalProperties": false

This is the instance to validate:

{

The three property sets are:

   s  [ "p1", "p2", "a32&o", "", "fiddle", "apple" ]

   p  [ "p1" ]

   pp [ "p", "[0-9]" ]

应用算法的两个步骤:

      after the first step, "p1" is removed from "s";

      after the second step, "p2" (matched by "p"), "a32&o" (matched by
      "[0-9]") and "apple" (matched by "p") are removed from "s".

集合"%s"仍然包含两个元素""和"小提琴".验证 因此失败了.

Json相关问答推荐

使用相同的密钥值来命名Json并使用Jolt重命名密钥

Vega通孔信号中的动态梯度

删除JSON文件的特定内容

如何在PowerShell中访问嵌套的JSON字段

如何判断响应数组是否存在以及S是否有其他内容...?

无法从MongoDB集合中检索正确的文档

使用 jq 和 awk 拆分大型 JSON 文件

使用 jq 获取特定键的所有父键

使用 BASH 和 JQ 我想将 json 文件与 bash 数组进行比较

使用 jq Select 键:值并输出为数组

如何为名称/值 struct 创建 JSON 模式?

使用 Spring 和 JsonTypeInfo 注释将 JSON 反序列化为多态对象模型

如何在 Perl 中将简单的哈希转换为 json?

如何在 swift 2 中获取 Alamofire.request().responseJSON 的结果值?

Golang struct 的 XML 和 JSON 标签?

有没有办法使用 Jackson 将 Map 转换为 JSON 表示而不写入文件?

在 Android 中使用带有 post 参数的 HttpClient 和 HttpPost

有没有办法折叠 Postman 中的所有 json 字段

通过 JSON 发送 64 位值的公认方式是什么?

仅使用字符串和值解析 JSON 对象