-
-
Save tenderlove/364192 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if !defined?(JSON) | |
require 'yajl' | |
else | |
require 'json' | |
module Yajl | |
LOOKUP = Hash[%w[null boolean string bytes int long float double].map { |x| [x.inspect, x] }] | |
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