Fix: [JSON-Query] Prevent parsing string-only JSON (#4425)

This commit is contained in:
Nelson Chan 2024-01-28 03:18:24 +08:00 committed by GitHub
parent 288cab6dd7
commit 2b8f55194f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -578,8 +578,12 @@ class Monitor extends BeanModel {
let data = res.data;
// convert data to object
if (typeof data === "string") {
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);