Skip to content

Error when resolving .length() expression in 2.5.0 #650

@lukas-krecan

Description

@lukas-krecan

After upgrading to 2.5.0, this code started to return strange results

        String json = "{\n" +
            "    \"store\": {\n" +
            "        \"book\": [\n" +
            "            {\n" +
            "                \"category\": \"reference\"\n" +
            "            },\n" +
            "            {\n" +
            "                \"category\": \"fiction\"\n" +
            "            },\n" +
            "            {\n" +
            "                \"category\": \"fiction\"\n" +
            "            },\n" +
            "            {\n" +
            "                \"category\": \"fiction\"\n" +
            "            }\n" +
            "        ]\n" +
            "    },\n" +
            "    \"expensive\": 10\n" +
            "}";


        Object result = using(Configuration.defaultConfiguration())
            .parse(json)
            .read("$..book.length()");
        System.out.println(result);

In 2.4.0 it returns an array containing number 4, in 2.5.0 it returns 2.

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