module TingYun::Support::HashExtensions

Public Instance Methods

stringify_keys_in_object(object) click to toggle source

recurses through hashes and arrays and stringifies keys

# File lib/ting_yun/support/hash_extensions.rb, line 10
def stringify_keys_in_object(object)
  case object
    when Hash
      object.inject({}) do |memo, (k, v)|
        memo[k.to_s] = stringify_keys_in_object(v)
        memo
      end
    when Array
      object.map {|o| stringify_keys_in_object(o)}
    else
      object
  end
end