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

JsonPointer parsing FieldName rule inconsistent #1361

Open
slz30 opened this issue Nov 15, 2024 · 0 comments
Open

JsonPointer parsing FieldName rule inconsistent #1361

slz30 opened this issue Nov 15, 2024 · 0 comments

Comments

@slz30
Copy link

slz30 commented Nov 15, 2024

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
    }
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

No branches or pull requests

1 participant