From 2b8f55194f7a4b21427cb02b2dcf6c662105c22f Mon Sep 17 00:00:00 2001 From: Nelson Chan <3271800+chakflying@users.noreply.github.com> Date: Sun, 28 Jan 2024 03:18:24 +0800 Subject: [PATCH] Fix: [JSON-Query] Prevent parsing string-only JSON (#4425) --- server/model/monitor.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/server/model/monitor.js b/server/model/monitor.js index 2dc77fbd..40cdd735 100644 --- a/server/model/monitor.js +++ b/server/model/monitor.js @@ -578,8 +578,12 @@ class Monitor extends BeanModel { let data = res.data; // convert data to object - if (typeof data === "string") { - data = JSON.parse(data); + if (typeof data === "string" && res.headers["content-type"] !== "application/json") { + try { + data = JSON.parse(data); + } catch (_) { + // Failed to parse as JSON, just process it as a string + } } let expression = jsonata(this.jsonPath);