Skip to content

RFC 8259 #85

Open
Open
@njzjz

Description

@njzjz

RFC 8259 的表述更严格一些,它说:

The names within an object SHOULD be unique.
其中大写的“SHOULD”是 RFC 的一个术语,表示特定情况下可以违反这个规则,但是要考虑到可能会导致的问题。

然而,YAML 1.2 说:

The content of a mapping node is an unordered set of key/value node pairs, with the restriction that each of the keys is unique.
这个规则是绝对的,YAML 1.2 解析器在遇到重复的键时必须报错。

但是注意到RFC 8259是这么说的

When the names within an object are not unique, the behavior of software that receives such an object is unpredictable. Many implementations report the last name/value pair only. Other implementations report an error or fail to parse the object, and some implementations report all of the name/value pairs, including duplicates.

也就是说YAML 1.2选择直接报错也是一种合法的unpredictable的JSON实现,未违反RFC 8259解析JSON的要求。

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions