Class: Embulk::Input::HttpInputPlugin::IterJson

Inherits:
Iter
  • Object
show all
Defined in:
lib/embulk/input/http.rb

Instance Method Summary collapse

Constructor Details

#initialize(data, path) ⇒ IterJson

Returns a new instance of IterJson.



148
149
150
151
152
# File 'lib/embulk/input/http.rb', line 148

def initialize(data, path)
  require "jsonpath"
  super
  @jsonpath = JsonPath.new(@path)
end

Instance Method Details

#eachObject



154
155
156
157
158
159
# File 'lib/embulk/input/http.rb', line 154

def each
  @jsonpath.on(@data).flatten.each do |e|
    raise "data is must be hash, but #{e.class}" unless e.instance_of?(Hash)
    yield e
  end
end