Class: EasyJSONMatcher::JsonCoercer

Inherits:
Object
  • Object
show all
Defined in:
lib/easy_json_matcher/json_coercer.rb

Instance Method Summary collapse

Instance Method Details

#coerce(json:) ⇒ Object



7
8
9
10
11
12
13
# File 'lib/easy_json_matcher/json_coercer.rb', line 7

def coerce(json:)
  begin
    JSON.parse(json)
  rescue JSON::ParserError, TypeError
    raise CoercionError.new invalid_string: json
  end
end