51 lines
727 B
PHP
51 lines
727 B
PHP
<?php
|
|
|
|
class JsonBuilder
|
|
{
|
|
private $arguemnt_array;
|
|
|
|
function __construct()
|
|
{
|
|
$this->arguemnt_array = array();
|
|
}
|
|
|
|
function __destruct()
|
|
{
|
|
}
|
|
|
|
|
|
public function setData($name, $data)
|
|
{
|
|
$this->arguemnt_array[$name] = $data;
|
|
}
|
|
|
|
public function setErrorMessage($message)
|
|
{
|
|
$this->arguemnt_array["error"] = $message;
|
|
}
|
|
|
|
public function setErrorCode($code)
|
|
{
|
|
$this->setData("errorCode", $code);
|
|
}
|
|
|
|
public function send()
|
|
{
|
|
echo json_encode($this->arguemnt_array, JSON_UNESCAPED_UNICODE);
|
|
}
|
|
|
|
public function sendResultSuccess()
|
|
{
|
|
$this->arguemnt_array["result"] = "success";
|
|
$this->send();
|
|
}
|
|
|
|
public function sendResultFail()
|
|
{
|
|
$this->arguemnt_array["result"] = "fail";
|
|
$this->send();
|
|
}
|
|
|
|
}
|
|
|
|
?>
|