Monday, October 4, 2010

Check if string has JSON inside

module JSON
  def is_json?(string)
    begin
      parse(string).all?
    rescue ParserError
      false
    end
  end
end

No comments: