Module: Barometer::Utils::JsonReader

Defined in:
lib/barometer/utils/json_reader.rb

Class Method Summary collapse

Class Method Details

.parse(json, *nodes_to_remove) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/barometer/utils/json_reader.rb', line 6

def self.parse(json, *nodes_to_remove)
  output = JSON.parse(json)

  nodes_to_remove.each do |node|
    output = output.fetch(node, output)
  end

  if block_given? && output
    output = yield(output)
  end

  output
end