Embryo/Http/Message/Traits/ResponseTrait.php
public function withJson($data, int $status = null, int $options = 0)
        {
            $json = json_encode($data, $options);
            if ($json === false) {
                throw new \RuntimeException(json_last_error_msg(), json_last_error());
            }
            
            $response = $this->write($json);
            $response = $response->withHeader('Content-Type', 'application/json;charset=utf-8');
            
            if (isset($status)) {
                return $response->withStatus($status);
            }
            return $response;
        }
public function withJson($data, int $status = null, int $options = 0)
        {
            $json = json_encode($data, $options);
            if ($json === false) {
                throw new \RuntimeException(json_last_error_msg(), json_last_error());
            }
            
            $response = $this->write($json);
            $response = $response->withHeader('Content-Type', 'application/json;charset=utf-8');
            
            if (isset($status)) {
                return $response->withStatus($status);
            }
            return $response;
        }
public function withJson ( $ data , int $ status = null , int $ options = 0 ) { $ json = json_encode ( $ data , $ options ) ; if ( $ json === false ) { throw new \ RuntimeException ( json_last_error_msg ( ) , json_last_error ( ) ) ; } $ response = $ this -> write ( $ json ) ; $ response = $ response -> withHeader ( 'Content-Type' , 'application/json;charset=utf-8' ) ; if ( isset ( $ status ) ) { return $ response -> withStatus ( $ status ) ; } return $ response ; }
Prepares the response object to return an HTTP json
response to the client.

@param mixed $data
@param int $status
@param int $options
@return static
@throws RuntimeException
Prepares the response object to return an HTTP json response to the client .