RussellSpitzer / snakeyaml

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

Immutable object is not serialized with yaml.dump #153

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create Immutable class with constructor, only getters
2. serialize with yaml.dump(), no attributes are serialized
3. add a setter to any attribute
4. serialize again, this attribute gets serialized

What is the expected output? What do you see instead?
Serialized immutable with all attributes, only raw class, no attributes

What version of SnakeYAML are you using? On what Java version?
SnakeYAML 1.11-SNAPSHOTS, Java 1.6

Please provide any additional information below. (Often a failing test is
the best way to describe the problem.)
see attached Test

Original issue reported on code.google.com by nchor...@csc.com on 7 Jul 2012 at 4:37

Attachments:

GoogleCodeExporter commented 9 years ago
Have you tried DumpOptions ?

<code language="java">
DumpOptions o = new DumpOptions();
o.setAllowReadOnlyProperties(true);
Yaml yaml = new Yaml(o);
</code>

Original comment by alexande...@gmail.com on 7 Jul 2012 at 6:39

GoogleCodeExporter commented 9 years ago
Sorry, didn't try yet. I was just curious why a missing setter affects the 
serializing. I thought that getters must be enough.

From:   snakeyaml@googlecode.com
To:     Nikolaus Chorherr/AUT/CSC@CSC
Date:   07.07.2012 20:37
Subject:        Re: Issue 153 in snakeyaml: Immutable object is not 
serialized with yaml.dump

Original comment by nchor...@csc.com on 9 Jul 2012 at 10:01

GoogleCodeExporter commented 9 years ago
By default, SnakeYAML can only process classes that conform to the JavaBean 
specification. A class without a setter is no JavaBean and it requires manual 
definition.

Original comment by py4fun@gmail.com on 9 Jul 2012 at 11:42

GoogleCodeExporter commented 9 years ago

Original comment by py4fun@gmail.com on 11 Jul 2012 at 2:30