Skip to content

Instantly share code, notes, and snippets.

@jmhodges
Created April 13, 2010 00:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jmhodges/364167 to your computer and use it in GitHub Desktop.
Save jmhodges/364167 to your computer and use it in GitHub Desktop.
if !defined?(JSON)
require 'yajl'
else
require 'json'
module Yajl
LOOKUP = %w[null boolean string bytes int long float double].
inject({}){|h,k| h[k.inspect] = k; h }
def self.dump(obj)
JSON.dump(obj)
end
def self.load(string)
LOOKUP[string] || JSON.load(string)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment