Hey,
I have some data that I output with YAML and read back in. I use these
for hashing. So It would be necessary that the read value is exactly the
same as the outputted value. But this is sometimes not the case.
The data is complex as it is a hash with an array of strings as keys and
an array of strings as values.
Now I wonder if this is an error or just my misunderstanding of YAML.
Here is the source code reproducing the error with the data file
attached.
I am using Marshal now again, as in my case it reproduces the data
exactly.
==================================================
require ‘yaml’
require ‘pp’
read the data with marshal
data1 = nil
File.open( “marshal”, “r”) {|file|
data1 = Marshal.load( file )
}
write and read with yaml
data2 = YAML.load data1.to_yaml
puts data1 == data2 # => false
put differences
File.open( “data1”, “w”) { |file|
PP.pp data1, file
}
File.open( “data2”, “w”) { |file|
PP.pp( data2, file )
}
system “diff data1 data2”