Better type handling

This commit is contained in:
Matt Visnovsky 2024-06-06 10:04:20 -06:00
parent efb1642e3c
commit 36dc94b8f2

View file

@ -399,11 +399,12 @@ function intHash(str, length = 10) {
exports.intHash = intHash; exports.intHash = intHash;
async function evaluateJsonQuery(data, jsonPath, jsonPathOperator, expectedValue) { async function evaluateJsonQuery(data, jsonPath, jsonPathOperator, expectedValue) {
const expected = isNaN(expectedValue) ? expectedValue.toString() : parseFloat(expectedValue); const expected = isNaN(expectedValue) ? expectedValue.toString() : parseFloat(expectedValue);
let response = isNaN(data) ? data.toString() : parseFloat(data); let response;
try { try {
response = JSON.parse(response); response = JSON.parse(data);
} }
catch (_) { catch (_a) {
response = typeof data === "number" || typeof data === "object" ? data : data.toString();
} }
let jsonQueryExpression; let jsonQueryExpression;
switch (jsonPathOperator) { switch (jsonPathOperator) {