youxinren / snakeyaml

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

Serialize Iterator and Iterable as sequences #69

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Iterator and Iterable are not dumped as sequences.

Original issue reported on code.google.com by py4fun@gmail.com on 25 Jun 2010 at 10:01

GoogleCodeExporter commented 9 years ago
Fixed. It will be delivered in release 1.7

http://code.google.com/p/snakeyaml/source/detail?r=cc30f1a62b35cbdf4bd7430775ce8
1abff5e7f17

Original comment by aso...@gmail.com on 25 Jun 2010 at 5:37

GoogleCodeExporter commented 9 years ago
Not changing the status or creating a new issue, but now I am a bit concerned...
Since I do not know prehistory here comes the question: 
How do you load dumped object back?
Implementing Iterator or Iterable may expose internal data of the object to 
iterate over/remove it using those interfaces, but it is not necessary 
everything what object has inside.
For example, it could be JavaBean with some content inside which is accessible 
by Iterator and some other important properties not dependent on iterable 
content. In this case: 
 1. You will lose all bean's properties but those you are able to iterate over. 
 2. You will get an Exception trying to load dumped yaml doc. Since object itself is not the the sequence, Constructor will try to create it as immutable object (issue 19) trying to find suitable constructor based on dumped sequence values, it will fail of course.... Even if we skip Constructor search it will fail anyway since expected object is not a sequence.  

I think this could be useful feature (may be for docs exchange between 
different languages or something else), but I doubt its existence as a default 
behavior.

Original comment by alexande...@gmail.com on 16 Sep 2010 at 6:13

GoogleCodeExporter commented 9 years ago
Indeed Iterable is not merely a container of objects.
Iterable should be serialised as a JavaBean while Iterator is still treated as 
a sequence of objects.
This will be implemented in 1.8 release

Original comment by py4fun@gmail.com on 16 Sep 2010 at 11:37