Created
December 15, 2018 08:28
-
-
Save akinazuki/6c3f92feb2cf147aee15a5977aa3c0b6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class JSON { | |
public static function Decode($string, $return_array = false, $depth = 512, $options = 0) { | |
$res = json_decode($string, $return_array, $depth, $options); | |
if (json_last_error() !== JSON_ERROR_NONE) { | |
throw new Exception(json_last_error(), json_last_error_msg()); | |
} | |
return $res; | |
} | |
public static function Encode($array, $options = 0, $depth = 512) { | |
$res = json_encode($array); | |
if (json_last_error() !== JSON_ERROR_NONE) { | |
throw new Exception(json_last_error(), json_last_error_msg()); | |
} | |
return $res; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment