Output JSON

    protected function json_response($code=200, $message='', $data=null){
        http_response_code($code);
        //Output;
        header('Cache-Control: no-cache, must-revalidate');
        header('Content-type: application/json;charset=utf-8');

        $out = array(
            'code' => $code, 
            'message' => $message, 
            'data' => $data
        );
        echo json_encode($out);
        exit();
    }