Skip to content

JsonPointer parsing of '~' not followed by "0" or "1" unexpected #1361

@slz30

Description

@slz30

JsonPointer is compatible with non escaped characters~, but this compatibility fails when~is located at the end of FieldName and followed by /. Here is a simple example

public static void main(String[] args) {
        ObjectMapper om = new ObjectMapper();
        ObjectNode jo = om.createObjectNode();
        ArrayNode nums = om.createArrayNode().add(0).add(1);
        jo.set("num~s",nums);
        JsonPointer jp = JsonPointer.compile("/num~s/0");
        System.out.println(jo.at(jp)); //print 0

        jo.remove("num~s");
        jo.set("nums~",nums);
        jp = JsonPointer.compile("/nums~");
        System.out.println(jo.at(jp)); //print [0,1]

        jo.remove("num~s");
        jo.set("nums~",nums);
        jp = JsonPointer.compile("/nums~/0");
        System.out.println(jo.at(jp).isMissingNode()); // is missingNode
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    2.19Issues planned at earliest for 2.19

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions