-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Re-Enable default values for text nodes #4496
Comments
Similar to #4471 |
@JooHyukKim exactly, thanks for pointing that out, didn't find that ticket |
Kinda valid point. Also, as per JavaDoc.. * NOTE: deprecated since 2.17 because {@link #asText()} very rarely returns
* {@code null} for any node types -- in fact, neither {@link MissingNode}
* nor {@code NullNode} return {@code null} from {@link #asText()}. ... it was deprecated for the code path being dead cold, but un-deprecation requests tell otherwise. 🤔 |
@henning-meinhardt Did you not actually try to search for an existing issue? The very previous open one, #4471 covers this. So let's discuss there; closing this as duplicate. |
@cowtowncoder you are right, i should have found this, but unfortunately the issue did no exist yet when I stumbled upon the problem. Just came to report it yesterday. Sorry for inconvenience. Seems to be problem that bothers not just me ;-) |
Is your feature request related to a problem? Please describe.
Starting with Jackson databind 2.17 the method
JsonNode.asText(String defaultValue)
was deprecated without giving an advice how to fill the missing functionality. In #463 you added the possibility to return a default value when querying a missing text node like so:When property
property
was not present, value was set todefaultValue
. According to the deprecation comment this method should not be used any longer. But there is no advice how to implement the use case "go with a default value when the property in question is not defined" in an adequately short manner. At least I could not find any useful replacement around the JsonNode class. Is there something I missed?Describe the solution you'd like
I would like you to rethink the deprecation or provide an easy replacement (in one statement) for getting a text property value or a fallback when missing.
I also just commented on #463 giving the workarounds I came up so far, both much too complicated compared to the existing method. There I also tried to explain why the given reason for deprecation doesn't seem valid to me.
Usage example
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: