CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/maven-com-amazonaws--jmespath-java

Implementation of the JMES Path JSON Query language for Java

Pending
Overview
Eval results
Files

core-expressions.mddocs/

Core Expressions

Fundamental expression types that form the building blocks of JMESPath queries. These expressions handle basic JSON navigation, field access, literals, and compound operations.

Capabilities

Field Access Expression

Accesses a field from a JSON object using field names. Supports camelCase conversion for compatibility.

public class JmesPathField implements JmesPathExpression {
    /**
     * Creates a field access expression for the specified field name
     * @param value The field name to access
     */
    public JmesPathField(String value);
    
    /**
     * Gets the field name being accessed
     * @return The field name
     */
    public String getValue();
    
    public <Input, Output> Output accept(JmesPathVisitor<Input, Output> visitor, Input input) 
        throws InvalidTypeException;
}

Usage Example:

// Access "name" field from JSON object
JmesPathField nameField = new JmesPathField("name");
JsonNode result = nameField.accept(visitor, jsonObject);

Identity Expression

Returns the current JSON node unchanged. Used as a placeholder or base for other operations.

public class JmesPathIdentity implements JmesPathExpression {
    /**
     * Creates an identity expression that returns the input unchanged
     */
    public JmesPathIdentity();
    
    public <Input, Output> Output accept(JmesPathVisitor<Input, Output> visitor, Input input) 
        throws InvalidTypeException;
}

Usage Example:

// Identity expression - returns input as-is
JmesPathIdentity identity = new JmesPathIdentity();
JsonNode result = identity.accept(visitor, inputData);

Literal Expression

Represents literal JSON values (strings, numbers, booleans, objects, arrays) within expressions.

public class JmesPathLiteral implements JmesPathExpression {
    /**
     * Creates a literal expression from a string value
     * @param value The literal string value
     */
    public JmesPathLiteral(String value);
    
    /**
     * Creates a literal expression from a JsonNode value
     * @param value The literal JsonNode value
     */
    public JmesPathLiteral(JsonNode value);
    
    /**
     * Gets the literal value as a JsonNode
     * @return The JsonNode representation of the literal
     */
    public JsonNode getValue();
    
    public <Input, Output> Output accept(JmesPathVisitor<Input, Output> visitor, Input input) 
        throws InvalidTypeException;
}

Usage Example:

// Create literal values
JmesPathLiteral stringLiteral = new JmesPathLiteral("hello");
JmesPathLiteral numberLiteral = new JmesPathLiteral(mapper.valueToTree(42));

Sub-Expression (Chained Access)

Chains multiple expressions together, evaluating them in sequence where each result becomes the input for the next expression.

public class JmesPathSubExpression implements JmesPathExpression {
    /**
     * Creates a sub-expression from individual expressions
     * @param expressions Variable number of expressions to chain
     */
    public JmesPathSubExpression(JmesPathExpression... expressions);
    
    /**
     * Creates a sub-expression from a list of expressions
     * @param expressions List of expressions to chain
     */
    public JmesPathSubExpression(List<JmesPathExpression> expressions);
    
    /**
     * Gets the list of chained expressions
     * @return List of expressions in evaluation order
     */
    public List<JmesPathExpression> getExpressions();
    
    public <Input, Output> Output accept(JmesPathVisitor<Input, Output> visitor, Input input) 
        throws InvalidTypeException;
}

Usage Example:

// Chain expressions: user.profile.name
JmesPathSubExpression chainedAccess = new JmesPathSubExpression(
    new JmesPathField("user"),
    new JmesPathField("profile"),
    new JmesPathField("name")
);
JsonNode result = chainedAccess.accept(visitor, data);

Multi-Select List Expression

Creates an array by evaluating multiple expressions against the same input and collecting their results.

public class JmesPathMultiSelectList implements JmesPathExpression {
    /**
     * Creates a multi-select list from individual expressions
     * @param expressions Variable number of expressions to evaluate
     */
    public JmesPathMultiSelectList(JmesPathExpression... expressions);
    
    /**
     * Creates a multi-select list from a list of expressions
     * @param expressions List of expressions to evaluate
     */
    public JmesPathMultiSelectList(List<JmesPathExpression> expressions);
    
    /**
     * Gets the list of expressions to evaluate
     * @return List of expressions
     */
    public List<JmesPathExpression> getExpressions();
    
    public <Input, Output> Output accept(JmesPathVisitor<Input, Output> visitor, Input input) 
        throws InvalidTypeException;
}

Usage Example:

// Multi-select: [name, age, email]
JmesPathMultiSelectList multiSelect = new JmesPathMultiSelectList(
    new JmesPathField("name"),
    new JmesPathField("age"),
    new JmesPathField("email")
);
JsonNode result = multiSelect.accept(visitor, userObject);
// Result: ["Alice", 30, "alice@example.com"]

Type Definitions

Visitor Interface

public interface JmesPathVisitor<Input, Output> {
    Output visit(JmesPathField fieldNode, Input input);
    Output visit(JmesPathIdentity jmesPathIdentity, Input input);
    Output visit(JmesPathLiteral literal, Input input);
    Output visit(JmesPathSubExpression subExpression, Input input) throws InvalidTypeException;
    Output visit(JmesPathMultiSelectList multiSelectList, Input input) throws InvalidTypeException;
    Output visit(JmesPathProjection jmesPathProjection, Input input) throws InvalidTypeException;
    Output visit(JmesPathValueProjection valueProjection, Input input) throws InvalidTypeException;
    Output visit(JmesPathFlatten flatten, Input input) throws InvalidTypeException;
    Output visit(JmesPathFunction function, Input input) throws InvalidTypeException;
    Output visit(JmesPathFilter filter, Input input) throws InvalidTypeException;
    Output visit(Comparator op, Input input) throws InvalidTypeException;
    Output visit(JmesPathNotExpression expression, Input input) throws InvalidTypeException;
    Output visit(JmesPathAndExpression expression, Input input) throws InvalidTypeException;
}

Install with Tessl CLI

npx tessl i tessl/maven-com-amazonaws--jmespath-java

docs

advanced-expressions.md

built-in-functions.md

comparison-operations.md

core-expressions.md

expression-evaluation.md

index.md

tile.json