From: William S. <sp...@rh...> - 2009-08-26 01:02:10
|
Oren Ben-Kiki wrote: > In general you can't force, or rely on, the order of the keys in the > file. That is, in general someone may apply some tool to the file (say a > pretty-printer) that will sort the keys alphabetically, or something, > and then you'd be SOL. Using tags as in the previous example is the > recommended way. Or, you may accept the overhead of creating the > temporary structure. Yes this is what I figured. I am using the parser/emitter api to libyaml and I certainly do not want any temporary object, both because of the overhead and because it will throw errors in different than lexical order from the file. > you _could_ mess up the file structure and do > something like: > > - a: { name: nameofa, a: value of a } > - b: { name: nameofb, b: value of b } > > But that's really just a dirtier form of tagging. I guess that would work. It has the advantage that it works in json (though it looks ugly there), while if I use tags I will never be able to produce legit json. Anyway I currently plan on using the tags. |