lib/hashie/extensions/stringify_keys.rb
# Convert all keys in the hash to strings.
#
# @param [::Hash] hash
# @example
#   test = {:abc => 'def'}
#   test.stringify_keys!
#   test # => {'abc' => 'def'}
Convert all keys in the hash to strings.
Convert all keys in the hash to strings .
def stringify_keys!(hash)
          hash.extend(Hashie::Extensions::StringifyKeys) unless hash.respond_to?(:stringify_keys!)
          hash.keys.each do |k| 
            stringify_keys_recursively!(hash[k])
            hash[k.to_s] = hash.delete(k)
          end
          hash
        end
def stringify_keys! ( hash ) hash . extend ( Hashie :: Extensions :: StringifyKeys ) unless hash . respond_to? ( :stringify_keys! ) hash . keys . each do | k | stringify_keys_recursively! ( hash [ k ] ) hash [ k . to_s ] = hash . delete ( k ) end hash end
Convert all keys in the hash to strings.
Convert all keys in the hash to strings .
# rubocop:disable Performance/HashEachMethods
hash
None
example
test = {:abc => 'def'} test.stringify_keys.
test = { : abc = > ' def ' } test . stringify_keys .