YAML symbols

B

braver

YAML writes out Ruby symbols as !ruby/sym, e.g. :name => 'John'
becomes

!ruby/sym name: John

I write out megabytes of data, so I played with replacing !ruby/sym
with a simple colon:

:name: John

-- and it gets loaded back just as the !ruby/sym version!

Is there a way to instruct YAML to dump plain colon ':' instead of "!
ruby/sym "? Is reading back my version a guaranteed behavior?

Cheers,
Alexy
 
E

eden li

Weird... which version of YAML are you using? It doesn't generate !
ruby/sym for me:

$ ruby -v -r yaml -e 'puts({:name => "John", :yaml_version =>
YAML::VERSION}.to_yaml)'
ruby 1.8.4 (2005-12-24) [i486-linux]
 
S

Swanand

Weird... which version of YAML are you using? It doesn't generate !
ruby/sym for me:

$ ruby -v -r yaml -e 'puts({:name => "John", :yaml_version =>
YAML::VERSION}.to_yaml)'
ruby 1.8.4 (2005-12-24) [i486-linux]
---
:yaml_version: "0.60"
:name: John

YAML writes out Ruby symbols as !ruby/sym, e.g. :name => 'John'
becomes
!ruby/sym name: John
I write out megabytes of data, so I played with replacing !ruby/sym
with a simple colon:
:name: John
-- and it gets loaded back just as the !ruby/sym version!
Is there a way to instruct YAML to dump plain colon ':' instead of "!
ruby/sym "? Is reading back my version a guaranteed behavior?
Cheers,
Alexy


Hi!
Same here! It is not placing ! in my case as well. As per the
YAML.rb documentation it should.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,240
Messages
2,571,211
Members
47,845
Latest member
vojosay

Latest Threads

Top