Serialize with Marshal, YAML, or what?


#1

If I want to serialize/unserialize arbitrary objects (not just ARs) in a
Rails app, what’s the best way to do it?

Using ‘Marshal’ seems to be ruby standard. But then there’s YAML. And
then I feel like maybe Rails adds yet another way to do it, but I can’t
remember what it is and might be imagining that.

I don’t understand the plusses/minuses of each option. I just want to be
able to serialize/unserialize arbitrary objects, what’s my best bet?

Jonathan


#2

On Dec 3, 5:47 pm, Jonathan R. <rails-mailing-l…@andreas-
s.net> wrote:

If I want to serialize/unserialize arbitrary objects (not just ARs) in a
Rails app, what’s the best way to do it?

Using ‘Marshal’ seems to be ruby standard. But then there’s YAML. And
then I feel like maybe Rails adds yet another way to do it, but I can’t
remember what it is and might be imagining that.

Well an important thing is who are you talking to: Marshal is quite
easy to read from a ruby program but anything else and you’re probably
out of luck. YAML on the other hand is more portable.

Fred