public function do($data, string $type = 'unescaped_unicode') : string { $return = json_encode($data, Converter::toConstant($type, 'JSON_')); if (ErrorInfo::no()) { throw new JsonErrorException('[Json::encode()] -> ' . ErrorInfo::message()); } return $return; }
public function do(string $data, bool $array = false, int $length = 512) { $return = json_decode($data, $array, $length); if (ErrorInfo::no()) { try { throw new JsonErrorException('[Json::decode()] -> ' . ErrorInfo::message()); } catch (JsonErrorException $e) { $e->continue(); } } return $return; }