Skip to content

oxvshappymapper

MIT 7 4 911
214.0 thousand (month) Jul 01 2011 2.14.23(2025-05-28 01:01:53 ago)
152 7 23 MIT
Mar 19 2010 41.1 thousand (month) 0.10.1(2025-10-25 16:03:51 ago)

Ox is a Ruby gem that provides a simple and efficient way to parse and generate XML and JSON documents. It is built on top of the underlying C library libox, which is known for its speed and low memory usage. Ox provides a simple and intuitive API for parsing and generating XML and JSON documents, and it is widely used in the Ruby ecosystem for web scraping, web development, and data-gathering applications.

One of the main features of Ox is its ability to parse and generate XML and JSON documents with low memory usage. Ox uses a pull-based parsing strategy, which allows it to parse large documents without loading the entire document into memory, thus making it more efficient than other parsing libraries. Ox also provides a fast and efficient way of generating XML and JSON documents.

Ox also provides a variety of other features that can simplify the process of working with XML and JSON documents. It can automatically handle character encodings, it can parse and generate documents with minimal memory usage, and it can validate documents against a DTD or schema.

Happymapper allows you to parse XML data and convert it quickly and easily into ruby data structures.

Happymapper maps XML structures to ruby data structures which then can be parsed for data using any other Ruby data tools. This also means, happymaker can convert XML to JSON as ruby data structures are easily exportable to JSON

Example Use


```ruby require 'ox' class Sample attr_accessor :a, :b, :c def initialize(a, b, c) @a = a @b = b @c = c end end # Create Object obj = Sample.new(1, "bee", ['x', :y, 7.0]) # Now dump the Object to an XML String. xml = Ox.dump(obj) # Convert the object back into a Sample Object. obj2 = Ox.parse_obj(xml) ```
```ruby require 'happymapper' xml = '
Milchstrasse 23 26131 Oldenburg Germany
' # we can parse it as is: address = HappyMapper.parse(ADDRESS_XML_DATA) address.street # => Milchstrasse address.housenumber # => 23 address.postcode # => 26131 address.city # => Oldenburg address.country.code # => de address.country.content # => Germany # or define a structure class Address include HappyMapper tag 'address' element :street, String, tag: 'street' element :postcode, String, tag: 'postcode' element :housenumber, Integer, tag: 'housenumber' element :city, String, tag: 'city' element :country, String, tag: 'country' end Address.parse(xml) ```

Alternatives / Similar


Was this page helpful?