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
···
--
--------
David Pollak's Ruby Playground
http://dppruby.com
David Pollak wrote:
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
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
···
On Wed, 26 Jul 2006, David Pollak wrote:
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
--
suffering increases your inner strength. also, the wishing for suffering
makes the suffering disappear.
- h.h. the 14th dali lama
David Pollak wrote:
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.
···
--
Alex
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)?
I've had that in one of my rails projects. Luckily it was for a cache, and
it only happened sporadically. So my solution was to catch the exception
and just not read that cache file back in, but recreating it from its
source. You might of course not have that option.
I have posted on ruby-core about it, but haven't gotten much
interest/feedback. I even had a file that threw an exception on each
YAML.load. (Which I deleted some time ago)
http://thread.gmane.org/gmane.comp.lang.ruby.core/6996
No help offered there, but I wanted to show compassion... 
kaspar
···
--
neotrivium.com - swiss ruby shop
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.
···
On 25/07/06, David Pollak <pollak@gmail.com> wrote:
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)?
I'm enclosing a file that contains a Marshal'ed array. To reproduce
the failure:
gunzip enclosed file
a = Marshal.load(enclosed_file)
a == YAML.load(YAML.dump(a))
f.m.gz (2.63 KB)
···
On 7/25/06, ara.t.howard@noaa.gov <ara.t.howard@noaa.gov> wrote:
On Wed, 26 Jul 2006, David Pollak wrote:
> 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
--
suffering increases your inner strength. also, the wishing for suffering
makes the suffering disappear.
- h.h. the 14th dali lama
--
--------
David Pollak's Ruby Playground
http://dppruby.com