def json
      return @json if defined?(@json)
      # no content, no JSON
      if @response.code.to_s == '204'
        data = {}
      elsif @response.body.blank?
        # no body, no json
        data = {message: @response.message.blank? ? 'empty body' : @response.message.strip}
      end
      begin
        data ||= JSON.parse(@response.body)
      rescue ::Exception => e
        data = { message: "Invalid JSON - #{e.message} for:\n#{@response.body}" }
      end
      # indifferent access to hashes
      data = data.is_a?(Array) ? data.map(&:with_indifferent_access) : data.with_indifferent_access
      # empty OK response is not seen as an error
      data = {} if data.is_a?(Hash) && data.size == 1 && data[:message] == 'OK'
      # prepend HTTP response code to message
      data[:message] = "#{response.code}: #{data[:message]}" unless @response.is_a?(Net::HTTPSuccess)
      @json = data
    end
def json
      return @json if defined?(@json)
      # no content, no JSON
      if @response.code.to_s == '204'
        data = {}
      elsif @response.body.blank?
        # no body, no json
        data = {message: @response.message.blank? ? 'empty body' : @response.message.strip}
      end
      begin
        data ||= JSON.parse(@response.body)
      rescue ::Exception => e
        data = { message: "Invalid JSON - #{e.message} for:\n#{@response.body}" }
      end
      # indifferent access to hashes
      data = data.is_a?(Array) ? data.map(&:with_indifferent_access) : data.with_indifferent_access
      # empty OK response is not seen as an error
      data = {} if data.is_a?(Hash) && data.size == 1 && data[:message] == 'OK'
      # prepend HTTP response code to message
      data[:message] = "#{response.code}: #{data[:message]}" unless @response.is_a?(Net::HTTPSuccess)
      @json = data
    end
The JSON value, if single resource is queried this is a Hash, if multiple resources where queried it is an Array
 If the response is not +valid?+ it is a Hash with 'message' and optionally 'errors'