def _read_payload(self):
        """ Reads the payload (=data) """
        comm('reading payload data')
        comm('remaining bytes to read: %d', self._to_read)
        data_read = self.read(self._to_read)
        nb_bytes_read = len(data_read)
        comm('%d bytes read', nb_bytes_read)
        self._data_buf += data_read
        self._to_read -= nb_bytes_read
        if self._to_read <= 0:
            try:
                data = self._data_buf.decode('utf-8')
            except AttributeError:
                data = bytes(self._data_buf.data()).decode('utf-8')
            comm('payload read: %r', data)
            comm('payload length: %r', len(self._data_buf))
            comm('decoding payload as json object')
            obj = json.loads(data)
            comm('response received: %r', obj)
            try:
                results = obj['results']
            except (__HOLE__, TypeError):
                results = None
            # possible callback
            if self._callback and self._callback():
                self._callback()(results)
            self._header_complete = False
            self._data_buf = bytes()
            self.finished.emit(self)
dataset/ETHPy150Open OpenCobolIDE/OpenCobolIDE/open_cobol_ide/extlibs/pyqode/core/api/client.py/JsonTcpClient._read_payload