# Rails 2.0 serialize

**URL:** <https://www.ruby-forum.com/t/rails-2-0-serialize/117738>\
**Category:** Rails\
**Created:** [October 19, 2007, 8:37pm UTC](https://www.ruby-forum.com/t/rails-2-0-serialize/117738 "2007-10-19T20:37:20Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![rlwinter](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ecccb3/32.png) [@rlwinter](https://www.ruby-forum.com/u/rlwinter)\
**Post date:** [October 19, 2007, 8:37pm UTC](https://www.ruby-forum.com/t/rails-2-0-serialize/117738/1 "2007-10-19T20:37:20Z")

</div>

ActiveRecord in Rails 1.2.x has a method: serialize(attr\_name,  
class\_name = Object). I was wondering, given the new JSON  
serialization in 2.0, if it will be possible to request JSON instead  
of YAML when serializing data to a database column? Same goes for XML.  
It seems logical to modify the method to: serialize(column\_name,  
options = {}).

Then you could do something like:

class User \< ActiveRecord::Base  
serialize :preferences,  
:class\_name =\> ‘Hash’,  
:format =\> :json  
end
