| Newsgroups |
gmane.text.yaml.general |
| Message-ID |
<[email protected]> |
Dear all:
when processing data through a load - modify - dump cycle, the YAML
parser eats what it considers "presentation details", and the YAML
emitter produces output that is much less readable than my original
hand-formatted input.
(To be specific: I have tons of data lines like
- [ 0, 3, 2, 5, 9, 9, 9, 0, 0, 1, 12, 1, 3, 3, 2, 0, 0, 14 ]
which I occasionally need to inspect by eye.
If they are presented like
- - 0
- 3
<and so on>
the main advantage of YAML (cf. the order of priorities in spec 1.1)
is lost.)
Spec 3.1.3 explains nicely why this problem is inevitable. It correctly
concludes that the presentation needs to be "guided by the preferences
of the user". However, it does not say how this guidance can be imposed
on a YAML emitter.
I could think of two ways to guide a YAML emitter:
(1) On scripting language level: To use Ruby terms, one could introduce
class and instance variables of YAML, String, Array and Hash in order
to specify at various levels how an entity should be formatted. Kind
of
a = [ 0, 3, 2, 5 ] # create Array
a.yaml_hints.push( YAML.InlineAlways )
(2) On the level of YAML specification, allow a simple way to preformat
data structures within YAML dumps. Say, I want to dump a complex entity
ydat that somewhere contains my precious array,
ydat["Data"]["essential"][197] = [ 0, 3, 2, 5 ].
As I do not like the default format of the emitter, I replace the array
by a string,
ydat["Data"]["essential"][197] = "[ 0, 3, 2, 5 ]".
Dumping ydat, I obtain
---
Data:
essential:
- <197 similar lines>
- "[ 0, 3, 2, 5 ]"
...
Obviously, the emitter added double quotes in order to prevent interpreting
the string as an array. However, that would have been exactly what I wanted !
So, there should be a way of preventing a string containing a data structure
from being quoted. Something like
ydat["Data"]["essential"][197] = "\<[ 0, 3, 2, 5 ]>".
should produce
---
Data:
essential:
- <197 similar lines>
- [ 0, 3, 2, 5 ]
...
Regards, Joachim
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone