rufus-json
One interface for various JSON Ruby backends.
# load your favourite JSON backend require 'yajl' #require 'json' #require 'active_support' p Rufus::Json.decode('{"a":2,"b":true}') # => { 'a' => 2, 'b' => true } p Rufus::Json.encode({ 'a' => 2, 'b' => true }) # => '{"a":2,"b":true}'
If multiple libs are present, it will favour yajl-ruby and json, and then active_support. It’s OK to force a backend.
Rufus::Json.backend = :yajl #Rufus::Json.backend = :json #Rufus::Json.backend = :active
To know if there is currently a backend set :
Rufus::Json.has_backend?
It’s OK to load a lib and force detection :
require 'json' Rufus::Json.detect_backend p Rufus::Json.backend # => :json
There is a dup method, it may be useful in an all JSON system (flattening stuff that will anyway get flattened later).
o = Rufus::Json.dup(o)
rdoc
rufus.rubyforge.org/rufus-json/
mailing list
On the rufus-ruby list :
groups.google.com/group/rufus-ruby
issue tracker
github.com/jmettraux/rufus-json/issues
irc
irc.freenode.net #ruote
the rest of Rufus
authors
- John Mettraux, jmettraux.wordpress.com/
license
MIT