mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-08-21 07:37:38 +08:00
Query json directly rather than with $.value
-This is less abstract -Maximum compatibility with @chakflying's existing json-query monitor code.
This commit is contained in:
14
src/util.js
14
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.");
|
||||
}
|
||||
|
Reference in New Issue
Block a user