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

Change JsonNode.with(String) and withArray(String) to consider argument as JsonPointer if valid expression #3568

Closed
cowtowncoder opened this issue Aug 9, 2022 · 1 comment

Comments

@cowtowncoder
Copy link
Member

With #1980 there are new methods/overloads for withArray() and with(), which take JsonPointer.
The old methods that take String should be retrofitted in 2.x so that:

  1. If argument is valid JsonPointer (that is, starts with leading '/` or is empty String ""), it should be used as such
  2. Only if argument is not a valid JsonPointer, should it check existing property.

For Jackson 3.0 we can just drop the check and expect valid JsonPointer String representation.

The reason for change is to make expected main use case work, while retaining reasonable backwards-compatibility.

@cowtowncoder cowtowncoder added to-evaluate Issue that has been received but not yet evaluated 2.14 and removed to-evaluate Issue that has been received but not yet evaluated labels Aug 9, 2022
@cowtowncoder cowtowncoder changed the title Change JsonNode.with(String) and withArray(String) to consider argument as JsonPointer (if valid) Change JsonNode.with(String) and withArray(String) to consider argument as JsonPointer if valid expression Aug 10, 2022
cowtowncoder added a commit that referenced this issue Aug 10, 2022
cowtowncoder added a commit that referenced this issue Aug 10, 2022
cowtowncoder added a commit that referenced this issue Aug 10, 2022
@dan2097
Copy link

dan2097 commented Aug 27, 2023

The reason for change is to make expected main use case work, while retaining reasonable backwards-compatibility.

For the corner case where a user is creating/fetching keys that start with a forward slash this change is unequivocally not backwards compatible. Given that with was deprecated as part of #3535 did its behaviour really need to change...

(I'm not personally effected by this change, was just wondering what the closest replacement for the deprecated with() method was as the Javadoc didn't provide a suggestion, and was surprised to see the JsonPointer parsing logic. As far as I can see there isn't an exact replacement if you want your input interpreted as a literal key. For my use case putObject was actually appropriate)

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

2 participants