From f5e7fcf51fcaff47384d58f285f672916b4619af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=91=E6=9E=97?= Date: Fri, 23 Sep 2022 18:59:35 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=98=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- function.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/function.php b/function.php index 66f4ecc2..fa535912 100644 --- a/function.php +++ b/function.php @@ -35,6 +35,18 @@ if (!function_exists('make')) { return Kiri::getDi()->get($name); } +} + + +if (!function_exists('isJson')) { + + + function isJson(?string $string): bool + { + if (is_null($string)) return false; + return str_starts_with($string, '{') && str_starts_with($string, '[') + && str_ends_with($string, '}') && str_ends_with($string, ']'); + } }