1

Is there a way to disable ruby 2.0.0 YAML's suffixing with ruby type info?

I just upgraded to ruby 2.0.0 and I'm having YAML problems. I read-update-write a yaml file that previously looked like this

test:
  test2:
    somevar: hello

When I feed this into ruby 200, it reads OK but writes:

test: !ruby/object:Hash
  test2: !ruby/object:Hash
    somevar: hello

When I rerun the program YAML.load reads nothing.

myH = YAML.load_file( YAML_FPATH )
puts "Yaml as Hash:" + myH.inspect
>> Yaml as Hash: {}

Curiously, if I pass the "test: !ruby/object:Hash" version of the file to ruby 1.8.7, it reads the suffixed file OK and writes a non-suffixed file.

4

1 回答 1

0

发现问题:我修改了 hash.to_yaml 以便对键进行排序。由于我的代码基于 hash.to_yaml 1.8.7,我需要根据 hash.to_yaml 2.0.0 对其进行修改。

于 2013-10-24T23:00:10.737 回答