Module: Xlgrep::InvalidJson

Defined in:
lib/xlgrep/invalid_json.rb

Class Method Summary collapse

Class Method Details

.match(str) ⇒ Object



7
8
9
10
11
12
13
14
15
# File 'lib/xlgrep/invalid_json.rb', line 7

def match(str)
  if str =~ /\A\{.*\}\Z|\A\[.*\]\Z/
    begin
      JSON.parse(str)
    rescue JSON::ParserError => e
      yield(e.message)
    end
  end
end