XF 2.1 REST API - Disable JSON_PRETTY_PRINT?

Covert

Member
Is there any way to disable the responses from being formatted?

There isn't a benefit to having it enabled in production since it only increases response sizes and CPU usage.

Appreciate any help!
 
I tried this, but the response was still using JSON_PRETTY_PRINT.
PHP:
<?php

namespace Example\XF\Mvc\Renderer;

class Json extends XFCP_Json
{
    protected function initialize()
    {
        parent::initialize();

        $this->encodeModifiers = JSON_UNESCAPED_SLASHES;
    }
}

Am I doing something wrong?
 
@TickTackk Appreciate the help, I got it working now.

REST API
PHP:
<?php

namespace Example\XF\Api\Mvc\Renderer;

class Api extends XFCP_Api
{
    protected function initialize()
    {
        parent::initialize();

        $this->encodeModifiers = JSON_UNESCAPED_SLASHES;
    }
}

UI (tooltip, etc)
PHP:
<?php

namespace Example\XF\Mvc\Renderer;

class Json extends XFCP_Json
{
    protected function initialize()
    {
        parent::initialize();

        $this->encodeModifiers = JSON_UNESCAPED_SLASHES;
    }
}
 
Top Bottom