Sha256: 3b525ded6efefbdcd05b2102797358d2def6205cde2aab695ea21a7d79ac8931

Contents?: true

Size: 370 Bytes

Versions: 3

Compression:

Stored size: 370 Bytes

Contents

# frozen_string_literal: true

require 'json'

# Extension to String for deserializing JSON
class String
  #
  # Convert this {String} into a JSON Hash
  #
  # @raise [WeeseError] If JSON parse fails
  #
  # @return [Hash] Hash representing the given JSON
  #
  def deserialize
    JSON.parse(self)
  rescue JSON::ParserError => e
    raise WeeseError, e.to_s
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
weese-1.0.2 lib/weese/deserialize.rb
weese-1.0.1 lib/weese/deserialize.rb
weese-1.0.0 lib/weese/deserialize.rb