module Faraday::DecodeMethods

def dehash(hash, depth)

@!visibility private
FIXME: this is not compatible with Rack::Utils.parse_nested_query
Internal: convert a nested hash with purely numeric keys into an array.
def dehash(hash, depth)
  hash.each do |key, value|
    hash[key] = dehash(value, depth + 1) if value.is_a?(Hash)
  end
  if depth.positive? && !hash.empty? && hash.keys.all? { |k| k =~ /^\d+$/ }
    hash.sort.map(&:last)
  else
    hash
  end
end