Skip to content

Add "JsonPointer#appendProperty" and "JsonPointer#appendIndex"Β #684

@LouizFC

Description

@LouizFC

When working heavily with JsonPointers, the following patterns usually emerges:

JsonPointer root = JsonPointer.compile("/a/b");
/// ... code
String property = "c"
root.append(JsonPointer.compile("/" + property));
/// or
JsonPointer.compile(root + "/" + property)

This is quite verbose, also a bit error prone, because it is easy to forget to add the / before each append.

Also, I found no easy way of appending slash characters without prior escaping.

So the two methods proposed should help with both convenience and some edge cases. The only thing that worries me is overusing/misusing this methods. Jackson JsonPointer is head centric, appending to the tail is expensive, so maybe documenting a warning should be good?

I will open a PR when I get some free time. I did a similar thing in the past, so I think I can probably reuse the tests from there.

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