Sha256: b43e71a56fdd9bed2cd4db61a51d3eeda6e71e9524a7063610cd7ceca1754916

Contents?: true

Size: 882 Bytes

Versions: 26

Compression:

Stored size: 882 Bytes

Contents

require 'json' unless defined?(JSON)

module ActiveSupport
  module JSON
    ParseError = ::JSON::ParserError unless const_defined?(:ParseError)

    module Backends
      module JSONGem
        extend self

        # Converts a JSON string into a Ruby object.
        def decode(json)
          data = ::JSON.parse(json)
          if ActiveSupport.parse_json_times
            convert_dates_from(data)
          else
            data
          end
        end

      private
        def convert_dates_from(data)
          case data
            when DATE_REGEX
              DateTime.parse(data)
            when Array
              data.map! { |d| convert_dates_from(d) }
            when Hash
              data.each do |key, value|
                data[key] = convert_dates_from(value)
              end
            else data
          end
        end
      end
    end
  end
end

Version data entries

26 entries across 25 versions & 7 rubygems

Version Path
radiantcms-couchrest_model-0.2.4 vendor/rails/activesupport/lib/active_support/json/backends/jsongem.rb
radiantcms-couchrest_model-0.2.2 vendor/rails/activesupport/lib/active_support/json/backends/jsongem.rb
radiantcms-couchrest_model-0.2.1 vendor/rails/activesupport/lib/active_support/json/backends/jsongem.rb
radiantcms-couchrest_model-0.2 vendor/rails/activesupport/lib/active_support/json/backends/jsongem.rb
radiantcms-couchrest_model-0.1.9 vendor/rails/activesupport/lib/active_support/json/backends/jsongem.rb
radiantcms-couchrest_model-0.1.8 vendor/rails/activesupport/lib/active_support/json/backends/jsongem.rb
radiantcms-couchrest_model-0.1.7 vendor/rails/activesupport/lib/active_support/json/backends/jsongem.rb
radiantcms-couchrest_model-0.1.6 vendor/rails/activesupport/lib/active_support/json/backends/jsongem.rb
radiantcms-couchrest_model-0.1.5 vendor/rails/activesupport/lib/active_support/json/backends/jsongem.rb
radiant-0.8.2 vendor/rails/activesupport/lib/active_support/json/backends/jsongem.rb
usher-0.7.0 spec/rails2_3/vendor/rails/vendor/rails/activesupport/lib/active_support/json/backends/jsongem.rb
usher-0.7.0 spec/rails2_3/vendor/rails/vendor/rails/activesupport/pkg/activesupport-2.3.3/lib/active_support/json/backends/jsongem.rb
ginst-2009.12.8 vendor/rails/activesupport/lib/active_support/json/backends/jsongem.rb
ginst-2009.11.24 vendor/rails/activesupport/lib/active_support/json/backends/jsongem.rb
ginst-2009.11.23 vendor/rails/activesupport/lib/active_support/json/backends/jsongem.rb
ginst-2.0.1 vendor/rails/activesupport/lib/active_support/json/backends/jsongem.rb
ginst-2.0.0 vendor/rails/activesupport/lib/active_support/json/backends/jsongem.rb
gemstreamer-1.2.0 spec/assets/testapp/vendor/rails/activesupport/lib/active_support/json/backends/jsongem.rb
gemstreamer-1.1.1 spec/assets/testapp/vendor/rails/activesupport/lib/active_support/json/backends/jsongem.rb
gemstreamer-1.1.0 spec/assets/testapp/vendor/rails/activesupport/lib/active_support/json/backends/jsongem.rb