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

Add JsonNode.isEmpty() as convenience alias #2204

Closed
cowtowncoder opened this issue Dec 11, 2018 · 0 comments
Closed

Add JsonNode.isEmpty() as convenience alias #2204

cowtowncoder opened this issue Dec 11, 2018 · 0 comments
Milestone

Comments

@cowtowncoder
Copy link
Member

An often-used idiom for checking for empty Arrays and Object for JsonNode is:

if (arrayNode.size() == 0) { // is empty
}

and due to common use, would make sense to allow use via alias

if (arrayNode.isEmpty()) { ...
}

Semantically it makes sense for containers (Arrays, Objects). For scalars, we could either always return true, or have per-type logic.
I think that former makes more sense at this point even though there may be some confusing in contrast to JsonSerializer.isEmpty() (which does implement much more complex logic).

@cowtowncoder cowtowncoder added this to the 2.10.0 milestone Dec 11, 2018
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