YAML Broken?

D

David Pollak

Folks,

It seems that when I YAML.dump arrays that contain long strings that
contain non-printables and sometimes UTF-8 sequences, the YAML'ed
objects can't be read back in. Is this a known issue? If so, is
there a known work-around? Alternatively, are there any other ways to
serialize objects (JSON doesn't work because eval() barfs on very long
strings)?

Thanks,

David
 
J

Justin Collins

David said:
Folks,

It seems that when I YAML.dump arrays that contain long strings that
contain non-printables and sometimes UTF-8 sequences, the YAML'ed
objects can't be read back in. Is this a known issue? If so, is
there a known work-around? Alternatively, are there any other ways to
serialize objects (JSON doesn't work because eval() barfs on very long
strings)?

Thanks,

David
There's always Marshal.

http://ruby-doc.org/core/classes/Marshal.html

-Justin
 
A

ara.t.howard

Folks,

It seems that when I YAML.dump arrays that contain long strings that
contain non-printables and sometimes UTF-8 sequences, the YAML'ed
objects can't be read back in. Is this a known issue? If so, is
there a known work-around? Alternatively, are there any other ways to
serialize objects (JSON doesn't work because eval() barfs on very long
strings)?

Thanks,

David

can you show an example?


harp:~ > ruby -r yaml -e' nul = 0.chr; y(YAML.load(YAML.dump(nul)) == nul) '
true

harp:~ > ruby -v
ruby 1.8.4 (2005-12-01) [i686-linux]


-a
 
A

Alex Young

David said:
Folks,

It seems that when I YAML.dump arrays that contain long strings that
contain non-printables and sometimes UTF-8 sequences, the YAML'ed
objects can't be read back in. Is this a known issue? If so, is
there a known work-around? Alternatively, are there any other ways to
serialize objects (JSON doesn't work because eval() barfs on very long
strings)?
If you're on Windows, check you're reading and writing in binary mode...
Not sure if that's what'll be causing your problem, but it's tripped
me up before.
 
P

Paul Battley

It seems that when I YAML.dump arrays that contain long strings that
contain non-printables and sometimes UTF-8 sequences, the YAML'ed
objects can't be read back in. Is this a known issue? If so, is
there a known work-around? Alternatively, are there any other ways to
serialize objects (JSON doesn't work because eval() barfs on very long
strings)?

Are you using 1.8.4? I was bitten by this in Ruby 1.8.2, and actually
managed to track it down to a specific combination (when a hash key
was a string containing both 0x00 and 0x0A in a non-final position).
That specific bug seems to be fixed in 1.8.4, however.

Paul.
 

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,209
Messages
2,571,088
Members
47,686
Latest member
sparada

Latest Threads

Top