Skip to content

Add JsonNode.isEmpty() as convenience alias #2204

@cowtowncoder

Description

@cowtowncoder

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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions