Class: Solanum::Matcher::JSONReader

Inherits:
Solanum::Matcher show all
Defined in:
lib/solanum/matcher.rb

Overview

JsonReader matches a JSON-formatted input string and passes the parsed object to the block body.

Instance Attribute Summary

Attributes inherited from Solanum::Matcher

#fn

Instance Method Summary collapse

Methods inherited from Solanum::Matcher

#initialize

Constructor Details

This class inherits a constructor from Solanum::Matcher

Instance Method Details

#call(input) ⇒ Object



60
61
62
63
64
65
66
67
68
# File 'lib/solanum/matcher.rb', line 60

def call(input)
  begin
    json = JSON.parse(input)
    @fn.call(json)
  rescue => e
    STDERR.puts("Error matching JSON input: #{e.inspect}")
    {}
  end
end