lib/soaspec/exchange_handlers/rest_handler.rb in soaspec-0.0.36 vs lib/soaspec/exchange_handlers/rest_handler.rb in soaspec-0.0.37
- old
+ new
@@ -225,9 +225,10 @@
case Interpreter.response_type_for(exchange.response)
when :xml
path = '//' + path if path[0] != '/'
xpath_value_for(exchange: exchange, xpath: path)
when :json
+ path = '$..' + path if path[0] != '$'
matching_values = JsonPath.on(exchange.response.body, path)
raise NoElementInHash, "Element in #{exchange.response.body} not found with path '#{path}'" if matching_values.empty?
matching_values.first
else
raise 'Unrecognised response message. Neither xml nor json detected'
\ No newline at end of file