src/Web/Formatters/JsonResponseFormatter.php
public function format($response)
    {
        if ($this->contentType === null) {
            $this->contentType = $this->useJsonp
                ? self::CONTENT_TYPE_JSONP
                : self::CONTENT_TYPE_JSON;
        } elseif (strpos($this->contentType, 'charset') === false) {
            $this->contentType .= '; charset=UTF-8';
        }
        $response->getHeaders()->set('Content-Type', $this->contentType);
  
        if ($this->useJsonp) {
            return $this->formatJsonp($response);
        } else {
            return $this->formatJson($response);
        }
    }
public function format($response)
    {
        if ($this->contentType === null) {
            $this->contentType = $this->useJsonp
                ? self::CONTENT_TYPE_JSONP
                : self::CONTENT_TYPE_JSON;
        } elseif (strpos($this->contentType, 'charset') === false) {
            $this->contentType .= '; charset=UTF-8';
        }
        $response->getHeaders()->set('Content-Type', $this->contentType);
  
        if ($this->useJsonp) {
            return $this->formatJsonp($response);
        } else {
            return $this->formatJson($response);
        }
    }
Formats the specified response.
@param ResponseBuilderInterface $response the response to be formatted.
@return string