Module: JSON

Defined in:
lib/semantics3.rb

Class Method Summary collapse

Class Method Details

.is_json?(foo) ⇒ Boolean

Returns:

  • (Boolean)


294
295
296
297
298
299
300
301
# File 'lib/semantics3.rb', line 294

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