Sha256: 4591dfc779ed64a20c45b5ccc94c9d109ada3a7ca587f28087081dd64097c635
Contents?: true
Size: 922 Bytes
Versions: 2
Compression:
Stored size: 922 Bytes
Contents
require 'active_support' unless defined?(::ActiveSupport::JSON) module MultiJson module Engines # Use ActiveSupport to encode/decode JSON. class ActiveSupport def self.decode(string, options = {}) #:nodoc: hash = ::ActiveSupport::JSON.decode(string) options[:symbolize_keys] ? symbolize_keys(hash) : hash end def self.encode(object) #:nodoc: ::ActiveSupport::JSON.encode(object) end def self.symbolize_keys(hash) #:nodoc: hash.inject({}){|result, (key, value)| new_key = case key when String then key.to_sym else key end new_value = case value when Hash then symbolize_keys(value) else value end result[new_key] = new_value result } end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
multi_json-0.0.4 | lib/multi_json/engines/active_support.rb |
multi_json-0.0.3 | lib/multi_json/engines/active_support.rb |