module ActiveSupport::JSON::Backends::OkJson

def convert_dates_from(data)

def convert_dates_from(data)
  case data
  when nil
    nil
  when DATE_REGEX
    begin
      DateTime.parse(data)
    rescue ArgumentError
      data
    end
  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

def decode(json)

Parses a JSON string or IO and convert it into an object
def decode(json)
  if json.respond_to?(:read)
    json = json.read
  end
  data = ActiveSupport::OkJson.decode(json)
  if ActiveSupport.parse_json_times
    convert_dates_from(data)
  else
    data
  end
end