Sha256: 79e458460039455ebad8e556be1b280aeb076f5c9c935b38a51b5abec2d19927

Contents?: true

Size: 228 Bytes

Versions: 21

Compression:

Stored size: 228 Bytes

Contents

# frozen_string_literal: true

# Monkey patching the Ruby Core class String
class String
  # ...
  def valid_json?
    JSON.parse(self)
    true
  rescue JSON::ParserError
    false
  end

  alias is_valid_json? valid_json?
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
cotcube-helpers-0.2.3 lib/cotcube-helpers/string_ext.rb
cotcube-helpers-0.2.2.5 lib/cotcube-helpers/string_ext.rb
cotcube-helpers-0.2.2.4 lib/cotcube-helpers/string_ext.rb
cotcube-helpers-0.2.2.3 lib/cotcube-helpers/string_ext.rb
cotcube-helpers-0.2.1.1 lib/cotcube-helpers/string_ext.rb
cotcube-helpers-0.2.0 lib/cotcube-helpers/string_ext.rb
cotcube-helpers-0.1.10 lib/cotcube-helpers/string_ext.rb
cotcube-helpers-0.1.9.2 lib/cotcube-helpers/string_ext.rb
cotcube-helpers-0.1.9.1 lib/cotcube-helpers/string_ext.rb
cotcube-helpers-0.1.9 lib/cotcube-helpers/string_ext.rb
cotcube-helpers-0.1.8 lib/cotcube-helpers/string_ext.rb
cotcube-helpers-0.1.7.4 lib/cotcube-helpers/string_ext.rb
cotcube-helpers-0.1.7.3 lib/cotcube-helpers/string_ext.rb
cotcube-helpers-0.1.7.2 lib/cotcube-helpers/string_ext.rb
cotcube-helpers-0.1.7.1 lib/cotcube-helpers/string_ext.rb
cotcube-helpers-0.1.7 lib/cotcube-helpers/string_ext.rb
cotcube-helpers-0.1.6 lib/cotcube-helpers/string_ext.rb
cotcube-helpers-0.1.5.4 lib/cotcube-helpers/string_ext.rb
cotcube-helpers-0.1.5.1 lib/cotcube-helpers/string_ext.rb
cotcube-helpers-0.1.5 lib/cotcube-helpers/string_ext.rb