JsonNode (AWS SDK for Java

JsonNode (AWS SDK for Java - 2.25.34)
All Known Implementing Classes:
ArrayJsonNode, BooleanJsonNode, EmbeddedObjectJsonNode, NullJsonNode, NumberJsonNode, ObjectJsonNode, StringJsonNode

public interface JsonNode

A node in a JSON document. Either a number, string, boolean, array, object or null. Also can be an embedded object, which is a non-standard type used in JSON extensions, like CBOR.

Created from a JSON document via parser() or parserBuilder().

The type of node can be determined using "is" methods like isNumber() and isString(). Once the type is determined, the value of the node can be extracted via the "as" methods, like asNumber() and asString().

  • Method Summary

    When isArray() is true, this returns the array associated with this node.

    boolean

    When isBoolean() is true, this returns the boolean associated with this node. When isEmbeddedObject() is true, this returns the embedded object associated with this node. When isNumber() is true, this returns the number associated with this node. When isObject() is true, this returns the object associated with this node. When isString(), is true, this returns the string associated with this node.

    Return an empty object node.

    When isObject() is true, this will return the result of Optional.ofNullable(asObject().get(child)). When isArray() is true, this will return the result of asArray().get(child) if child is within bounds.

    default boolean

    Returns true if this node represents a JSON array:

    default boolean

    Returns true if this node represents a JSON boolean:

    default boolean

    Returns true if this node represents a JSON "embedded object".

    default boolean

    Returns true if this node represents a JSON null:

    default boolean

    Returns true if this node represents a JSON number:

    default boolean

    Returns true if this node represents a JSON object:

    default boolean

    Returns true if this node represents a JSON string:

    <T> T

    Visit this node using the provided visitor.

  • Method Details

    • parser

    • parserBuilder

    • emptyObjectNode

      Return an empty object node.

    • isNumber

      default boolean isNumber()

      Returns true if this node represents a JSON number:

      See Also:
    • isString

      default boolean isString()

      Returns true if this node represents a JSON string:

      See Also:
    • isBoolean

      default boolean isBoolean()

      Returns true if this node represents a JSON boolean:

      See Also:
    • isNull

      default boolean isNull()

      Returns true if this node represents a JSON null:

    • isArray

      default boolean isArray()

      Returns true if this node represents a JSON array:

      See Also:
    • isObject

      default boolean isObject()

      Returns true if this node represents a JSON object:

      See Also:
    • isEmbeddedObject

      default boolean isEmbeddedObject()

      Returns true if this node represents a JSON "embedded object". This non-standard type is associated with JSON extensions, like CBOR or ION. It allows additional data types to be embedded in a JSON document, like a timestamp or a raw byte array.

      Users who are only concerned with handling JSON can ignore this field. It will only be present when using a custom JsonFactory via JsonNodeParser.Builder.jsonFactory(JsonFactory).

      See Also:
    • asNumber

      When isNumber() is true, this returns the number associated with this node. This will throw an exception if isNumber() is false.
      See Also:
    • asString

      When isString(), is true, this returns the string associated with this node. This will throw an exception if isString() ()} is false.
    • asBoolean

      boolean asBoolean()

      When isBoolean() is true, this returns the boolean associated with this node. This will throw an exception if isBoolean() is false.
    • asArray

      When isArray() is true, this returns the array associated with this node. This will throw an exception if isArray() is false.
    • asObject

      When isObject() is true, this returns the object associated with this node. This will throw an exception if isObject() is false.
    • asEmbeddedObject

      See Also:
    • visit

      Visit this node using the provided visitor.

    • text

      When isString(), isBoolean(), or isNumber() is true, this will return the value of this node as a textual string. If this is any other type, this will return null.
    • field

      When isObject() is true, this will return the result of Optional.ofNullable(asObject().get(child)). If this is any other type, this will return Optional.empty().
    • index

      When isArray() is true, this will return the result of asArray().get(child) if child is within bounds. If this is any other type or the child is out of bounds, this will return Optional.empty().

You Might Also Like