Welcome Guest, Not a member yet? Register   Sign In
How to return pure json
#1

(This post was last modified: 01-03-2021, 05:16 AM by chanyui.)

Hello,

I want to respond with json without spaces or line breaks.
This is because the size of the large json grows unnecessarily.




PHP Code:
  public function testapi()
  {
    $data = ['test1' => 1'test2'=> 2];
    return $this->response->setJSON($data);
  


response

Code:
{
    "test1": 1,
    "test2": 2
}


Is there a good way?
Reply


Messages In This Thread
How to return pure json - by chanyui - 01-03-2021, 05:10 AM
RE: How to return pure json - by includebeer - 01-03-2021, 07:31 AM
RE: How to return pure json - by chanyui - 01-03-2021, 09:29 AM



Theme © iAndrew 2016 - Forum software by © MyBB