From a68c2a6aa244d196d171eddd7cb16aebc204e7f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E5=8F=AF=E8=80=90?= <46134044+sdhzwc@users.noreply.github.com> Date: Fri, 8 Nov 2024 10:51:21 +0800 Subject: [PATCH] [Fix-16786][Datasource] Fix jdbc connect parameters json validation question (#16787) --- dolphinscheduler-ui/src/utils/json.ts | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/dolphinscheduler-ui/src/utils/json.ts b/dolphinscheduler-ui/src/utils/json.ts index 3ce941ddb5..347486ad6e 100644 --- a/dolphinscheduler-ui/src/utils/json.ts +++ b/dolphinscheduler-ui/src/utils/json.ts @@ -19,17 +19,11 @@ * Verify if it is in json format */ const isJson = (str: string) => { - if (typeof str === 'string') { - try { - const obj = JSON.parse(str) - if (typeof obj === 'object' && obj) { - return true - } else { - return false - } - } catch (e) { - return false - } + try { + const obj = JSON.parse(str) + return !!(typeof obj === 'object' && obj && !Array.isArray(obj)) + } catch (e) { + return false } }