From: Andrey S. <py...@gm...> - 2012-01-24 13:34:46
|
Hi all, SnakeYAML (YAML 1.1 for Java) recently got an issue. I think this topic is not clearly specified and I would like to get some clarification. The issue is here: http://code.google.com/p/snakeyaml/issues/detail?id=139 It is about the Merge Key Language-Independent Type (http://yaml.org/type/merge.html) When the keys are not unique in a normal mapping, then the last value wins for all the current YAML implementations. But the merge tag has the following definition: "If the value associated with the key is a single mapping node, each of its key/value pairs is inserted into the current mapping, unless the key already exists in it. " It means that for the merge tag the second value for the same key does not override the value. It looks like some parsers (libyaml ?) ignore this requirement, but some parsers try to respect it, which causes misunderstanding. What is the preferred way to deal with not unique keys for the merge tag ? Andrey SnakeYAML developer |
From: Oren Ben-K. <or...@be...> - 2012-01-24 14:34:07
|
Arrgghh. The wording in http://yaml.org/type/merge.html is correct. The http://code.google.com/p/snakeyaml/issues/detail?id=139 issue isn't really with the merge behavior; the problem is that someone assumed there can be more than one instance of the key to merge. I'm posting a reply on that thread. Oren. |
From: <kei...@bt...> - 2012-01-24 15:35:57
|
I have a large application using PyYAML which relies on merging of non-unique keys. If the values are strings, they are catenated; otherwise a list of all values with the same key is built. Will this be affected by any future changes to the specification? Thanks, Keith From: Oren Ben-Kiki [mailto:or...@be...] Sent: 24 January 2012 14:29 To: Andrey Somov Cc: YAML-Core Subject: Re: [Yaml-core] when the keys are not unique: mapping and merging Arrgghh. The wording in http://yaml.org/type/merge.html is correct. The http://code.google.com/p/snakeyaml/issues/detail?id=139 issue isn't really with the merge behavior; the problem is that someone assumed there can be more than one instance of the key to merge. I'm posting a reply on that thread. Oren. |
From: Andrey S. <py...@gm...> - 2012-01-25 10:27:53
|
Please be aware that you cannot rely on un-specified behavior. Your YAML document may be parsed differently on another platform (or even fail to parse !). PyYAML may also change the behavior as a bug fix for another reported problem. If you rely only on the explicitly specified features you are safe. If you miss something in the specification (or in the implementation) you may always ask a question here. Otherwise the parsers will get a bunch of hacks which are difficult to maintain. (even though the hack may look natural for one language or platform) - Andrey On Tue, Jan 24, 2012 at 4:35 PM, <kei...@bt...> wrote: > I have a large application using PyYAML which relies on merging of > non-unique keys. If the values are strings, they are catenated; otherwise > a list of all values with the same key is built. Will this be affected > by any future changes to the specification? > > Thanks, > > Keith > |