Closed GoogleCodeExporter closed 9 years ago
Unfortunately, YAML spec does not give recommended values for standard tags.
!!null has 5 values (http://yaml.org/type/null.html) and !!bool has 18 (!)
possible
values (http://yaml.org/type/bool.html)
For some (non-java) developers '~' is the natural way to represent 'null'.
I tried to configure the "default' values but it leads to very ugly code I have
remove it.
I have added a couple of examples to control values of standard tags.
Please have a look.
For null:
http://code.google.com/p/snakeyaml/source/browse/src/test/java/org/yaml/snakeyam
l/types/NullTagTest.java
For bool:
http://code.google.com/p/snakeyaml/source/browse/src/test/java/org/yaml/snakeyam
l/types/BoolTagTest.java
I think it it more flexible then the solution with ScalarAnalysis.
-
Andrey
Original comment by aso...@gmail.com
on 13 Apr 2010 at 8:39
Your advised solution is better.
However, the problem that I faced was that I demand that my output look a
certain
way. And I believe BaseRepresenter needs some more functions.
When I pre-processed my objects, I even made special objects so that those
alone
could be turned into blanks. Using representScalar(Tag.NULL,"") via
BaseRepresenter.representer has a different output than assigning a new
BaseRepresenter.nullRepresenter. (This triggers aliases to be made of the
blank.)
That is fine, now I understand, but.
But this does not help others with context dependent choices about how very
special
scalars get represented. I believe that BaseRepresenter needs some new
functions
like representNullAs(String x) when one is inside a custom represent object
and decides to make a late decision about outputting null (in 1 of 18 ways). This
might extend to booleans with representTrueAs and representFalseAs.
Original comment by shr...@gmail.com
on 20 Apr 2010 at 12:24
I do not see how your proposal may be implemented. Null and boolean have just a
few
possible values and we may create a method for each value. But what do we do
for Date
and int (integers may get underscores to separate thousands)? Can you may be
submit a
patch with the changes in the API ?
May be a better way is to make the implementations of Represent interface inside
SafeRepresenter public to simplify extension.
Original comment by aso...@gmail.com
on 20 Apr 2010 at 7:32
I will have to get back to about patches when I can peek into the code a bit.
Another representer hurdle:
[&id001]
How can I force that to happen with Representer?
Original comment by shr...@gmail.com
on 26 Apr 2010 at 1:17
Anchors ans aliases are automatically generated. You cannot (and should not)
try to
create them yourself. It may very easily lead to an inconsistent document.
N.B. I would prefer to have one topic per issue. It significantly simplifies
understanding and resolving issues.
Original comment by aso...@gmail.com
on 26 Apr 2010 at 7:22
The ticket will be closed because the reporter does not contribute anything.
Original comment by aso...@gmail.com
on 1 Oct 2010 at 8:00
Original issue reported on code.google.com by
shr...@gmail.com
on 12 Apr 2010 at 8:15