flight\Engine::_json PHP Method

_json() public method

Sends a JSON response.
public _json ( mixed $data, integer $code = 200, boolean $encode = true, string $charset = 'utf-8', integer $option )
$data mixed JSON data
$code integer HTTP status code
$encode boolean Whether to perform JSON encoding
$charset string Charset
$option integer Bitmask Json constant such as JSON_HEX_QUOT
    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();
    }