Skip to content

Commit

Permalink
Fix: [JSON-Query] Prevent parsing string-only JSON (#4425)
Browse files Browse the repository at this point in the history
  • Loading branch information
chakflying authored Jan 27, 2024
1 parent 288cab6 commit 2b8f551
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions server/model/monitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 2b8f551

Please sign in to comment.