Skip to content

Add method(s) in JsonNode that works like combination of at() and with(): withObject(...) and withArray(...) #1980

Closed
@cowtowncoder

Description

@cowtowncoder

Currently one can either:

  1. Locate a descendant node using at() OR
  2. Traverse immediate children, if one exists, or add one if not using with() and withArray()

but not something that would combine utility. But perhaps it would be enough to overload with() to take JsonPointer, and work similar to with except possible create longer path.
We might as well overload withArray() as well.

This will supercede #393.

EDIT: let's call methods withObject() and withArray() to indicate the expected node type to create. It will also be necessary to indicate allowed "replacement mode" in possible case of existing path being incompatible (f.ex expected path node being a scalar value), to determine whether to Replace the existing node (with Object/Array) or throw exception.

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