Method: Wdt::Authentication#stringify_keys
- Defined in:
- lib/wdt/authentication.rb
#stringify_keys(obj) ⇒ Object
把 hash 的 key 从 symbol 转化为 string params :b=>{:c=>2} return “b”=>{“c”=>2}
58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/wdt/authentication.rb', line 58 def stringify_keys(obj) return obj.reduce({}) do |memo, (k, v)| memo.tap { |m| m[k.to_s] = stringify_keys(v) } end if obj.is_a? Hash return obj.reduce([]) do |memo, v| memo << stringify_keys(v); memo end if obj.is_a? Array obj end |