Module: JSON

Defined in:
lib/semantics3.rb

Class Method Summary collapse

Class Method Details

.is_json?(foo) ⇒ Boolean

Returns:

  • (Boolean)


273
274
275
276
277
278
279
280
# File 'lib/semantics3.rb', line 273

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