From: Simon Chiang Date: 2009-03-30T12:53:37+09:00 Subject: [ruby-core:23062] [Bug #1331] YAML misformats hash with ruby object as key Bug #1331: YAML misformats hash with ruby object as key http://redmine.ruby-lang.org/issues/show/1331 Author: Simon Chiang Status: Open, Priority: Normal ruby -v: ruby 1.8.6 (2008-03-03 patchlevel 114) [universal-darwin9.0] YAML misformats the dump of hashes where the key is a user-defined ruby object. For instance: class A; end YAML.dump({A.new => :a}) Produces: --- !ruby/object:A ? {} : :a Which cannot be reloaded as YAML because the question mark is in the wrong place. The correctly formatted YAML is: --- ? !ruby/object:A {} : :a I have attached a couple tests with a patch illustrating how to work around this problem using gsub. Obviously a string substitution is not a long term solution, but I hope it illustrates what needs to be fixed. ---------------------------------------- http://redmine.ruby-lang.org