protected function checkResponseFormat(Response $response)
    {
        set_error_handler(function() { /* ignore errors */ });
        $arr = json_decode($response->getBody(), true, 512, 1);
        restore_error_handler();

        if (isset($arr['error'])) {
            throw new DiffbotException('Diffbot returned error ' . $arr['errorCode'] . ': ' . $arr['error']);
        }

        $required = [
            'objects' => 'Objects property missing - cannot extract entity values',
            'request' => 'Request property not found in response!'
        ];

        foreach ($required as $k=>$v) {
            if (!isset($arr[$k])) {
                throw new DiffbotException($v);
            }
        }

    }