Covert Member Jul 10, 2020 #1 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!
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!
Solution TickTackk Jul 10, 2020 You need to extend XF\Api\Mvc\Renderer\Api::initialize() and then update encodeModifiers property to suit your needs.
You need to extend XF\Api\Mvc\Renderer\Api::initialize() and then update encodeModifiers property to suit your needs.
TickTackk Well-known member Jul 10, 2020 #2 You need to extend XF\Api\Mvc\Renderer\Api::initialize() and then update encodeModifiers property to suit your needs. Last edited: Jul 10, 2020 Upvote 0 Downvote Solution
You need to extend XF\Api\Mvc\Renderer\Api::initialize() and then update encodeModifiers property to suit your needs.
Covert Member Jul 10, 2020 #3 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? Upvote 0 Downvote
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 Well-known member Jul 10, 2020 #4 I have edited my original message to show the right class name. Upvote 0 Downvote
Covert Member Jul 10, 2020 #5 @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; } } Upvote 1 Downvote
@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; } }