in apps/mountebank-mock/mountebank-source/src/models/jsonpath.js [20:42]
function select (selector, possibleJSON, logger) {
const isObject = helpers.isObject;
try {
const json = isObject(possibleJSON) ? possibleJSON : JSON.parse(possibleJSON),
result = JSONPath(selector, json);
if (typeof result === 'string') {
return result;
}
else if (result.length === 0) {
return undefined;
}
else {
return result;
}
}
catch (e) {
if (logger) {
logger.warn(`Cannot parse as JSON: ${JSON.stringify(possibleJSON)}`);
}
return undefined;
}
}