@aws-lambda-powertools/jmespath
Version:
A type safe and modern jmespath module to parse and extract data from JSON documents using JMESPath
26 lines (25 loc) • 729 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Expression = void 0;
/**
* Apply a JMESPath expression to a JSON value.
*/
class Expression {
#expression;
#interpreter;
constructor(expression, interpreter) {
this.#expression = expression;
this.#interpreter = interpreter;
}
/**
* Evaluate the expression against a JSON value.
*
* @param value The JSON value to apply the expression to.
* @param node The node to visit.
* @returns The result of applying the expression to the value.
*/
visit(value, node) {
return this.#interpreter.visit(node ?? this.#expression, value);
}
}
exports.Expression = Expression;