14 private $json_errors = null;
24 public function decode($json, $assoc =
false, $depth = 512)
27 if ($json ===
'' || $json === null) {
30 $o = json_decode($json, $assoc, $depth);
32 $errCode = json_last_error();
33 if ($errCode == JSON_ERROR_NONE) {
50 $str = json_encode(
$value, $options);
52 $errCode = json_last_error();
63 private function getErrorMsg($errCode)
65 if ($this->json_errors === null) {
66 $constants = get_defined_constants(
true);
67 foreach ($constants[
"json"] as $name =>
$value) {
68 if (!strncmp($name,
"JSON_ERROR_", 11)) {
69 $this->json_errors[
$value] = $name;
73 return $this->json_errors[$errCode];
Exception class use exceptionCode to identifiy correctly exception.
decode($json, $assoc=false, $depth=512)
encode($value, $options=0)