# Serialize with Marshal, YAML, or what?

**URL:** <https://www.ruby-forum.com/t/serialize-with-marshal-yaml-or-what/154769>\
**Category:** Rails\
**Created:** [December 3, 2008, 6:47pm UTC](https://www.ruby-forum.com/t/serialize-with-marshal-yaml-or-what/154769 "2008-12-03T18:47:22Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jrochkind](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/779978/32.png) [@jrochkind](https://www.ruby-forum.com/u/jrochkind)\
**Post date:** [December 3, 2008, 6:47pm UTC](https://www.ruby-forum.com/t/serialize-with-marshal-yaml-or-what/154769/1 "2008-12-03T18:47:22Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jrochkind](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/779978/32.png) [@jrochkind](https://www.ruby-forum.com/u/jrochkind)\
**Post date:** [December 3, 2008, 7:03pm UTC](https://www.ruby-forum.com/t/serialize-with-marshal-yaml-or-what/154769/2 "2008-12-03T19:03:06Z")

</div>

On Dec 3, 5:47 pm, Jonathan R. \<rails-mailing-l…@andreas-  
[s.net](http://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
