protected function formatJson($response)
    {
        $bodyRaw = $response->getRawBody();
        if ($bodyRaw !== null) {
            $options = $this->encodeOptions;
            if ($this->prettyPrint) {
                $options |= JSON_PRETTY_PRINT;
            }
            return $response->app instanceof Reaction\RequestApplicationInterface
                ? $response->app->helpers->json->encode($bodyRaw, $options)
                : Json::encode($bodyRaw, $options);
        }
        return '';
    }