Module: Ueki::HttpClient::JsonResponseBodyParser

Defined in:
lib/ueki/http_client/json_response_body_parser.rb

Overview

Simple JSON Parser (default) If it cannot be parsed as JSON, return the value before parsing

Class Method Summary collapse

Class Method Details

.call(body) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/ueki/http_client/json_response_body_parser.rb', line 12

def call(body)
  return if body.nil? || (body.is_a?(String) && body.empty?)

  JSON.parse(body, symbolize_names: true)
rescue JSON::ParserError
  body
end