Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filters like IN cannot process objects and arrays inside arrays #1016

Open
xceptance-dan opened this issue Jul 30, 2024 · 1 comment · May be fixed by #1017
Open

Filters like IN cannot process objects and arrays inside arrays #1016

xceptance-dan opened this issue Jul 30, 2024 · 1 comment · May be fixed by #1017

Comments

@xceptance-dan
Copy link

The issue can be reproduced by using the InEvaluator (IN filter) but other filters are affected as well. Below is a simplified JSON structure to show the problem.

[
    {
        "id": 1,
        "array": 
        [
            "a",
            {"b":"c"}
        ]
    }
]

Trying to get the object, which contains an array including the String "a" with:
$.*[?('a' in @.array)]

results in the following error:
Could not determine value type

This is because the toValueNode method in ValueNode.java does not deal properly with objects or arrays.

inEvaluator
asValueListNode
ValueListNode
toValueNode

@xceptance-dan
Copy link
Author

xceptance-dan commented Jul 30, 2024

Here's some code to quickly test the issue:
JsonPath.read("[{\"id\":1,\"array\":[\"a\",{\"b\":\"c\"}]}]", "$.*[?(\"a\" in @.array)]");

xceptance-dan pushed a commit to xceptance-dan/JsonPath that referenced this issue Jul 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant