Class: Hash

Inherits:
Object
  • Object
show all
Defined in:
lib/xplenty/kensa/okjson-support.rb

Instance Method Summary collapse

Instance Method Details

#stringify_keysObject



2
3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/xplenty/kensa/okjson-support.rb', line 2

def stringify_keys
  new_hash = {}
  each do |key, value|
    case value
    when Hash
      value = value.stringify_keys 
    when Array
      value = value.map { |v| v.stringify_keys if v.is_a? Hash } 
    end

    new_hash[key.to_s] = value
  end
  new_hash
end