protected function _format($data, array $context = [])
    {
        if (is_string($data)) {
            return $data;
        }

        $isObject = is_object($data);

        if ($isObject && $data instanceof EntityInterface) {
            return json_encode($data, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
        }

        if ($isObject && method_exists($data, '__toString')) {
            return (string)$data;
        }

        if ($isObject && $data instanceof JsonSerializable) {
            return json_encode($data, JSON_UNESCAPED_UNICODE);
        }

        return print_r($data, true);
    }