CodeIgniter Forums
return an unescaped json - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: return an unescaped json (/showthread.php?tid=77171)



return an unescaped json - leoz - 07-28-2020

Hi, i have some strings like 
Quote:["000"]
and with the classic $this->respond($mydata, 200) i can't unescape this. the json output is always "[\"000\"]"
I've also try
PHP Code:
    return $this->response->setStatusCode(200)
    ->setHeader('Content-Type''application/json')
    ->setBody(json_encode($mydataJSON_UNESCAPED_SLASHES)); 
but the result is the same.

Any suggestion?
Thanks in advance


RE: return an unescaped json - jreklund - 08-01-2020

Hi, check your app\Config\Format, that's where you find the formatter for the built in json encoder. And tweak it there.