Skip to content

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

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
    }

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions