Sha256: 22a309710aa44b274b3e2778471e8450783752bffc24fa0ee95596d3679df15e

Contents?: true

Size: 1.24 KB

Versions: 1

Compression:

Stored size: 1.24 KB

Contents

= Use X to JSON

Lots of Ruby libraries utilize JSON parsing in some form, and everyone has their favorite JSON library. In order to best support multiple JSON parsers and libraries, <tt>x_to_json</tt> is a general-purpose swappable JSON backend library. You use it like so:

    require 'x_to_json'
    
    XToJson.engine = :yajl
    XToJson.decode('{"abc":"def"}') # decoded using Yajl
    
    XToJson.engine = :json_gem
    XToJson.engine = XToJson::Engines::JsonGem # equivalent to previous line
    XToJson.encode({:abc => 'def'}) # encoded using the JSON gem
    
The <tt>engine</tt> setter takes either a symbol or a class (to allow for custom JSON parsers) that responds to both <tt>.decode</tt> and <tt>.encode</tt> at the class level.

== Note on Patches/Pull Requests
 
* Fork the project.
* Make your feature addition or bug fix.
* Add tests for it. This is important so I don't break it in a
  future version unintentionally.
* Commit, do not mess with rakefile, version, or history.
  (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
* Send me a pull request. Bonus points for topic branches.

== Copyright

Copyright (c) 2010 Michael Bleigh and Intridea, Inc. See LICENSE for details.

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
x_to_json-0.0.1 README.rdoc