Skip to content

Aggregation function attempted to calculate value using empty array #191

@transparentech

Description

@transparentech

In the 'store' example JSON, you can get a list of book prices using:

$.store.book[*].price

Or all prices:

$.store..price

What I tried to do is get the maximum price value using the max() function.

$.store..price.max()

However, this returns the error:

com.jayway.jsonpath.JsonPathException: Aggregation function attempted to calculate value using empty array

    at com.jayway.jsonpath.internal.function.numeric.AbstractAggregation.invoke(AbstractAggregation.java:62)
    at com.jayway.jsonpath.internal.path.FunctionPathToken.evaluate(FunctionPathToken.java:38)
    at com.jayway.jsonpath.internal.path.PathToken.handleObjectProperty(PathToken.java:81)
    at com.jayway.jsonpath.internal.path.PropertyPathToken.evaluate(PropertyPathToken.java:79)
    at com.jayway.jsonpath.internal.path.PathToken.handleArrayIndex(PathToken.java:133)
    at com.jayway.jsonpath.internal.path.WildcardPathToken.evaluate(WildcardPathToken.java:40)
    at com.jayway.jsonpath.internal.path.PathToken.handleObjectProperty(PathToken.java:81)
    at com.jayway.jsonpath.internal.path.PropertyPathToken.evaluate(PropertyPathToken.java:79)
    at com.jayway.jsonpath.internal.path.PathToken.handleObjectProperty(PathToken.java:81)
    at com.jayway.jsonpath.internal.path.PropertyPathToken.evaluate(PropertyPathToken.java:79)
    at com.jayway.jsonpath.internal.path.RootPathToken.evaluate(RootPathToken.java:62)
    at com.jayway.jsonpath.internal.path.CompiledPath.evaluate(CompiledPath.java:53)
    at com.jayway.jsonpath.internal.path.CompiledPath.evaluate(CompiledPath.java:61)
    at com.jayway.jsonpath.JsonPath.read(JsonPath.java:181)
    at com.jayway.jsonpath.internal.JsonContext.read(JsonContext.java:164)
    at com.jayway.jsonpath.internal.JsonContext.read(JsonContext.java:151)
    at com.jayway.jsonpath.JsonPath.read(JsonPath.java:502)

Is this a bug or is this type of function usage not yet supported?

I'm using the latest from 'master'.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions