Module: JSON

Defined in:
lib/stub_hub_api/response.rb

Overview

monkey patch for json

Class Method Summary collapse

Class Method Details

.is_json?(foo) ⇒ Boolean

Returns:

  • (Boolean)


6
7
8
9
10
11
12
13
# File 'lib/stub_hub_api/response.rb', line 6

def self.is_json?(foo)
  begin
    return false unless foo.is_a?(String)
    JSON.parse(foo).all?
  rescue JSON::ParserError
    false
  end
end