jsonbuilder

by nov http://github.com/nov <[email protected]> and
   birkirb http://github.com/birkirb

Description

Installation

git clone http://github.com/nov/jsonbuilder.git
cd jsonbuilder
rake install

Archive Installation

rake install

Gem Installation

gem install jsonbuilder --source http://gems.rubyforge.org

   OR for the lastest development version

gem install nov-jsonbuilder --source http://gems.github.com

Features/Problems

The Hash builder will return a hash structured in a similar way as the corresponding xml
built by XmlMarkup. The Json builder will return the same kind of hash as a JSON string

USAGE:
def serialize(builder, options = {})
  builder.user(
    :id => id,
    :url => url
  )
  builder.array_mode do
    builder.images do
      package.images.each do |image|
        builder << image.builder(builder.class.new, :only_url => true)
      end
    end
  end
  builder.target!
end

def to_xml(options = {})
  self.serialize(Builder::XMmlMarkup.new, options)
end

def to_hash(options = {})
  self.serialize(Builder::HashStructure.new, options)
end

def to_json(options = {})
  self.serialize(Builder::JsonFormat.new, options)
end

Synopsis

Author

nov <[email protected]> and birkirb

Copyright

Copyright © 2009 nov

License

MIT License