[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

YAML symbols

braver

4/19/2007 6:20:00 AM

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

2 Answers

eden li

4/19/2007 7:28:00 AM

0

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

On Apr 19, 2:20 pm, braver <delivera...@gmail.com> wrote:
> 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


Swanand

4/19/2007 11:17:00 AM

0

On Apr 19, 12:28 pm, eden li <eden...@gmail.com> wrote:
> 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
>
> On Apr 19, 2:20 pm, braver <delivera...@gmail.com> wrote:
>
> > 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.