public function _json(
        $data,
        $code = 200,
        $encode = true,
        $charset = 'utf-8',
        $option = 0
    ) {
        $json = ($encode) ? json_encode($data, $option) : $data;

        $this->response()
            ->status($code)
            ->header('Content-Type', 'application/json; charset='.$charset)
            ->write($json)
            ->send();
    }
public function _json(
        $data,
        $code = 200,
        $encode = true,
        $charset = 'utf-8',
        $option = 0
    ) {
        $json = ($encode) ? json_encode($data, $option) : $data;

        $this->response()
            ->status($code)
            ->header('Content-Type', 'application/json; charset='.$charset)
            ->write($json)
            ->send();
    }
public function _json ( $ data , $ code = 200 , $ encode = true , $ charset = 'utf-8' , $ option = 0 ) { $ json = ( $ encode ) ? json_encode ( $ data , $ option ) : $ data ; $ this -> response ( ) -> status ( $ code ) -> header ( 'Content-Type' , 'application/json; charset=' . $ charset ) -> write ( $ json ) -> send ( ) ; }
Sends a JSON response.

@param mixed $data JSON data
@param int $code HTTP status code
@param bool $encode Whether to perform JSON encoding
@param string $charset Charset
@param int $option Bitmask Json constant such as JSON_HEX_QUOT
@throws \Exception
Sends a JSON response .