Add: json_builder.php
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
<?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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user