On Sat, 2009-06-06 at 15:07 +0200, Jakob Voss wrote:
> The current YAML WD (Version 1.2, 2009-04-26) defines a mapping as an
> unordered association of unique keys to values (3.2.1., 18.104.22.168,
> 22.214.171.124). At the same time it is said that YAML can "be viewed as a
> natural superset of JSON" (1.3). BUT the JSON specification RFC 4627
> clearly states that "the names within an object SHOULD be
> Obviously most JSON parsers ignore multiple same names in one object
> with undefined behaviour (you can ignore all but the first, all but
> last, or all but a random entry or you can throw an error or warning).
Well then, this makes YAML processors no different from other JSON
processors then. That is, technically speaking, a YAML processor is a
valid JSON processor as per RFC 4627.
> That's fine unless all you deal with is a subset of JSON with unique
> names in objects.
I would claim this is not a "subset" of JSON, this _is_ JSON. That is,
if some misguided soul serialized PHP "ordered hashes" into JSON objects
(and had a PHP implementation that safely de-serialized it), I would
claim they are working outside the bounds of the JSON spec.
So, all in all, I don't see this as an issue. It may be worth a note
> BTW: Talking about subsets and subersets - is there an oficial name of
> the subset of YAML that only allows scalars as mapping keys? The
> failsafe schema explicitely does not place restrictions on the type of
> keys. In contrast most use cases and implementations will only allow
> scalar keys. I bet the situation will be similar to JSON where most
> people just ignore the "SHOULD"-clause on object keys in the
> specification - a situation that should be prevented by a good
Hmmm. This is an excellent question. I believe the resolution for this
- The failsafe schema is unaffected, as it should be safely applicable
to every YAML document - not necessarily JSON-compatible ones.
- The JSON schema should be restricted to disallow non-scalar keys, as
you correctly pointed out.
- The core schema is unaffected, as it is the "simple" extension of the
JSON schema to include basic YAML features - such as complex keys.
Very nice catch!