Project

badgerfish

0.0
No commit activity in last 3 years
No release in over 3 years
Badgerfish xml to json convention for ruby
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Development

< 5.0.0, >= 3.2.0
~> 1.3
~> 5.0.6
~> 1.7.9
~> 2.1.4
~> 0.9.12.2
~> 0.2.3
>= 0

Runtime

>= 2.1.1
 Project Readme

Badgerfish Build Status Dependency Status

BadgerFish is a convention for translating an XML document into a JSON object.

The rules

  • element names become object properties
  • text content of elements goes in the $ property of an object
  • nested elements become nested properties
  • multiple elements at the same level become array elements
  • attributes go in properties whose names begin with @
  • active namespaces for an element go in the element's @xmlns property
  • the default namespace URI goes in @xmlns.$
  • other namespaces go in other properties of @xmlns
  • elements with namespace prefixes become object properties, too

Installation

Add this line to your application's Gemfile:

gem 'badgerfish'

And then execute:

$ bundle

Or install it yourself as:

$ gem install badgerfish

Usage

require 'badgerfish'

parser = Badgerfish::Parser.new
xml = '<alice charlie="david">bob</alice>'
badgerfish_hash = parser.load(xml)

Missing features

Does not handle child node namespaces as suggested by http://badgerfish.ning.com (case 9).

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

Links