JsonObject Interface

Implements

public interface JsonObject
extends JsonNode

Interface that represents a JSON object.

Method Summary

Modifier and Type Method and Description
abstract Stream<String> fieldNames()

A Stream iterating over all field names in the object.

abstract Stream<java.util.Map.Entry<String,JsonNode>> fields()

A Stream iterating over all fields in the object.

abstract JsonNode get(String name)

Gets the JsonNode field with the specified name in the object.

abstract boolean has(String name)

Returns whether the object has a value for the specified field.

default boolean isObject()

Indicates whether this JsonNode is an instance of JsonObject ({}).

abstract JsonObject put(String name, JsonNode jsonNode)

Puts a JsonNode field with the specified name into the object.

abstract JsonNode remove(String name)

Removes the JsonNode with the specified name from the object.

abstract JsonNode set(String name, JsonNode jsonNode)

Sets the JsonNode field with the specified name with a new node value.

Method Details

fieldNames

public abstract Stream fieldNames()

A Stream iterating over all field names in the object.

Returns:

Stream for all field names in the object.

fields

public abstract Stream<>> fields()

A Stream iterating over all fields in the object.

Returns:

Stream for all fields in the object.

get

public abstract JsonNode get(String name)

Gets the JsonNode field with the specified name in the object.

Parameters:

name - Name of the node.

Returns:

JsonNode for the specified field in the object if it exist, null otherwise.

has

public abstract boolean has(String name)

Returns whether the object has a value for the specified field.

Parameters:

name - Name of the node.

Returns:

Whether the object has a value for the specified field.

isObject

public default boolean isObject()

Indicates whether this JsonNode is an instance of JsonObject ({}).

put

public abstract JsonObject put(String name, JsonNode jsonNode)

Puts a JsonNode field with the specified name into the object.

Parameters:

name - Name of the node.
jsonNode - The JsonNode to put into the object.

Returns:

The update JsonObject object.

remove

public abstract JsonNode remove(String name)

Removes the JsonNode with the specified name from the object.

Parameters:

name - Name of the node.

Returns:

JsonNode removed from the object if it existed, null otherwise.

set

public abstract JsonNode set(String name, JsonNode jsonNode)

Sets the JsonNode field with the specified name with a new node value.

Parameters:

name - Name of the node.
jsonNode - The new JsonNode value.

Returns:

The old JsonNode value if it was set, null otherwise.

Applies to