环境:ruby1.9.3,psych(任意版本) 例如:
o = { 'hash' => { 'name' => 'Steve', 'foo' => 'bar' } }
=> {"hash"=>{"name"=>"Steve", "foo"=>"bar"}}
#is there a inline option?
puts Psych.dump(o,{:inline =>true})
实际结果:
---
hash:
name: Steve
foo: bar
期望输出:
---
hash: { name: Steve, foo: bar }