On Sat, 2009-09-19 at 12:27 +0900, Osamu TAKEUCHI wrote:
> Hi all,
> The specification has the next statement in section 1.3.
> > every JSON file is also a valid YAML file.
> However, ... I learned the following.
> - JSON defines that the keys in a mapping node SHOULD be unique
> while YAML requires they MUST.
> - So, a YAML parser is a JSON parser.
> - But not every valid JSON document is a valid YAML document.
Not quite. JSON does not say that a JSON library MUST accept mappings
with duplicate keys; only that it SHOULD unless there's a good reason
not to. So a YAML library is technically a valid JSON library. It has a
good reason to reject duplicate keys (said reason is being a YAML
library, of course :-).
Put another way, a JSON file with duplicate keys is not a "safe" JSON
file - according to the JSON spec a JSON system MAY reject it. Which a
YAML-based JSON library does.
Anyone placing duplicate keys in his JSON files is in for a world of
hurt anyway. As you point out the JSON spec says you SHOULD NOT do that.
So don't :-)
> If my understanding is correct, I would like to have the spec
> to describe this point clearer or to permit duplicated keys
> in a mapping node.
Hmmm... perhaps so... I'd rather keep changes to the spec at this point
to be fixing errors, though, and this technically isn't one. I'll see if
its possible to sneak it in a sentence or two, though.