Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFC 8259 #85

Open
njzjz opened this issue May 6, 2024 · 0 comments
Open

RFC 8259 #85

njzjz opened this issue May 6, 2024 · 0 comments

Comments

@njzjz
Copy link

njzjz commented May 6, 2024

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的要求。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant