Badgerhash
Convert XML to a Ruby Hash using the BadgerFish convention: http://badgerfish.ning.com/
The resulting Hash can be easily converted to JSON using a JSON library.
The reference implementation of the generators use REXML for parsing the given XML. REXML is included in the Ruby Standard Library so no depencies are introduced. Nevertheless, this library provides interfaces that allow using alternate parsers if performance is a concern.
Installation
Add this line to your application's Gemfile:
gem 'badgerhash'
And then execute:
$ bundle
Or install it yourself as:
$ gem install badgerhash
Usage
Generating a BadgerFish Hash Using a Stream Parser
require "badgerhash"
require "stringio"
xml = StringIO.new("<alice>bob</alice>")
xml_stream = Badgerhash::XmlStream.create(xml)
puts xml_stream.to_badgerfish.inspect
Contributing
- Fork it ( http://github.com/gfmurphy/badgerhash/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request