yeison / snakeyaml

Automatically exported from code.google.com/p/snakeyaml
Apache License 2.0
0 stars 0 forks source link

Provide serialization with minimum layout change #66

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Can you provide an option which will make the serialized output look more
like the input?

For example i serialize stacktraces and want the dumped file as human
readable as possible. So linebreaks in the dumped file should be where they
are in the original input.

You can find detailed examples and a testcase in this discussion:
http://groups.google.com/group/snakeyaml-core/browse_thread/thread/7cc9200e1ba07
b81/18744a5d6659f34b#18744a5d6659f34b

Original issue reported on code.google.com by lerch.jo...@gmail.com on 27 Apr 2010 at 9:10

GoogleCodeExporter commented 9 years ago
It is a valuable enhancement. At the moment SnakeYAML tries to stay close to 
PyYAML
and emit the same document for the same input. 

Original comment by aso...@gmail.com on 27 Apr 2010 at 11:05

GoogleCodeExporter commented 9 years ago
> At the moment SnakeYAML tries to stay close to PyYAML
> and emit the same document for the same input. 

So what does that actaully mean? Are there plans to improve serialization in 
the near
future? Even if PyYAML serialization would look different? 

Original comment by marcel.b...@gmail.com on 28 Apr 2010 at 9:24

GoogleCodeExporter commented 9 years ago
- it explains why it works now in this way
- it opens a door for anyone who is going to contribute 
- those who wish to implement the enhancement may raise the question in the 
yaml-core
mailing list to get useful comments
- the impact of the deviation shall be evaluated. Some SnakeYAML users are 
confused
when they exchange documents with another parser. For instance SnakeYAML does 
not
emit "java:" for every global tag and simply puts "!!package.Class". Issue 57 
clearly
shows that when users get used to see some namespace indication (in Python and 
Ruby)
they expect the same in SnakeYAML.

I do not mind if SnakeYAML and PyYAML work differently but we shall understand 
the
consequence. In this particular case the change will make output better, but we 
may
contact PyYAML developers to make them aware that they can also make a step 
forward.
It may happend that PyYAML already now is able to output the stacktrace in a 
more
readable way.

Original comment by aso...@gmail.com on 28 Apr 2010 at 7:48

GoogleCodeExporter commented 9 years ago
I am just stepping by this issiue and I think it is preferable to have some 
kind of option for being compatible to the one side (PyYAML e.g.) and another 
option for having nicer output for those who don't care about compatibility.

Original comment by malte.ke...@de.equens.com on 10 Oct 2011 at 8:17

GoogleCodeExporter commented 9 years ago
I am afraid, I was wrong when I said that it is a compatibility issue.
We are free to change it. No worries about the possible impact. But the 
following stays:
- it explains why it works now in this way
- it opens a door for anyone who is going to contribute 

Feel free to look into Emitter.java (analyzeScalar(String scalar), 
chooseScalarStyle()), and/or contribute test cases for the dumper.

Original comment by aso...@gmail.com on 10 Oct 2011 at 8:59

GoogleCodeExporter commented 9 years ago
It should work better now. Try the latest source or the SNAPSHOT.

http://code.google.com/p/snakeyaml/source/browse/src/test/java/org/yaml/snakeyam
l/representer/DumpStackTraceTest.java (testJavaStackTraceWithoutTabs())

Please be aware that tabs now require the double quoted scalar style.

Original comment by aso...@gmail.com on 10 Oct 2011 at 4:07

GoogleCodeExporter commented 9 years ago
The fix will be provided in version 1.10

Original comment by aso...@gmail.com on 18 Oct 2011 at 2:29