diff --git a/src/lang/en.json b/src/lang/en.json index d95c3dd4..d1ed2f1b 100644 --- a/src/lang/en.json +++ b/src/lang/en.json @@ -577,7 +577,7 @@ "notificationDescription": "Notifications must be assigned to a monitor to function.", "keywordDescription": "Search keyword in plain HTML or JSON response. The search is case-sensitive.", "invertKeywordDescription": "Look for the keyword to be absent rather than present.", - "jsonQueryDescription": "Use JSON query to parse and extract specific data from the server's JSON response. Compare the evaluated query against the expected value after converting it into a string. Access the response value using $.value and the expected value using $.control. Refer to {0} for detailed documentation on the query language or experiment with queries using the {1}.", + "jsonQueryDescription": "Use JSON query to parse and extract specific data from the server's JSON response. Compare the evaluated query against the expected value after converting it into a string. Refer to {0} for detailed documentation on the query language or experiment with queries using the {1}.", "backupDescription": "You can backup all monitors and notifications into a JSON file.", "backupDescription2": "Note: history and event data is not included.", "backupDescription3": "Sensitive data such as notification tokens are included in the export file; please store export securely.", diff --git a/src/util.js b/src/util.js index 967c5b42..74774751 100644 --- a/src/util.js +++ b/src/util.js @@ -427,10 +427,16 @@ async function evaluateJsonQuery(data, jsonPath, jsonPathOperator, expectedValue throw new Error(`Invalid condition ${jsonPathOperator}`); } const expression = jsonata(jsonQueryExpression); - const evaluation = await expression.evaluate({ - value: response, - control: expected - }); + let evaluation; + if (jsonPathOperator === "custom") { + evaluation = await expression.evaluate(response); + } + else { + evaluation = await expression.evaluate({ + value: response, + control: expectedValue + }); + } if (evaluation === undefined) { throw new Error("Query evaluation returned undefined. Check your query syntax and the structure of the response data."); }