Module: Fluent::BigQuery::Helper

Defined in:
lib/fluent/plugin/bigquery/helper.rb

Class Method Summary collapse

Class Method Details

.deep_stringify_keys(object) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/fluent/plugin/bigquery/helper.rb', line 18

def deep_stringify_keys(object)
  case object
  when Hash
    object.each_with_object({}) do |(key, value), result|
      result[key.to_s] = deep_stringify_keys(value)
    end
  when Array
    object.map {|e| deep_stringify_keys(e) }
  else
    object
  end
end

.deep_symbolize_keys(object) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/fluent/plugin/bigquery/helper.rb', line 5

def deep_symbolize_keys(object)
  case object
  when Hash
    object.each_with_object({}) do |(key, value), result|
      result[key.to_sym] = deep_symbolize_keys(value)
    end
  when Array
    object.map {|e| deep_symbolize_keys(e) }
  else
    object
  end
end