[Nitro] Ruby library for serialization

transfire at gmail.com transfire at gmail.com
Wed Feb 14 11:23:29 EST 2007

On Feb 14, 9:35 am, "George Moschovitis"
<george.moschovi... at gmail.com> wrote:
> Dear devs,
> is there a Ruby library that can convert a Ruby object to XML, Atom, Json
> etc?
> I tried facets/more/json and facets/more/xoxo and they just use the .to_s
> method of the object, ie
> class Article
>   attr_accessor :title, :content, :author
>   def to_s; @title; end
> end
> a = Article.new
> a.title = 'hello'
> a.content = '...'
> a.author = 'george'
> a.to_json # => 'hello'
> which is not what I expected.
> any suggestions?

The JSON lib has #to_json, the XOXO lib has to_xoxo. There is a a way
to do XML serialization that's built-into ruby, but it's a little more
involved and I don't recall off hand how to do so. (Was it via the
soap lib?) Need to look that up --if you do please let us know.


More information about the Nitro-general mailing list