Class JsonNode.ObjectNode

java.lang.Object
cloud.opencode.base.json.JsonNode.ObjectNode
All Implemented Interfaces:
JsonNode
Enclosing interface:
JsonNode

public static final class JsonNode.ObjectNode extends Object implements JsonNode
Object Node - Represents a JSON object. 对象节点 - 表示 JSON 对象。
Since:
JDK 25, opencode-base-json V1.0.0
Author:
Leon Soo www.LeonSoo.com
  • Constructor Details

    • ObjectNode

      public ObjectNode()
  • Method Details

    • isObject

      public boolean isObject()
      Description copied from interface: JsonNode
      Returns whether this node is an object. 返回此节点是否为对象。
      Specified by:
      isObject in interface JsonNode
      Returns:
      true if object - 如果是对象则返回 true
    • get

      public JsonNode get(String key)
      Description copied from interface: JsonNode
      Gets a child node by property name (for objects). 按属性名获取子节点(用于对象)。
      Specified by:
      get in interface JsonNode
      Parameters:
      key - the property name - 属性名
      Returns:
      the child node, or null - 子节点,或 null
    • has

      public boolean has(String key)
      Description copied from interface: JsonNode
      Returns whether this node has a property (for objects). 返回此节点是否有属性(用于对象)。
      Specified by:
      has in interface JsonNode
      Parameters:
      key - the property name - 属性名
      Returns:
      true if has property - 如果有属性则返回 true
    • keys

      public Set<String> keys()
      Description copied from interface: JsonNode
      Returns the property names (for objects). For JsonNode.ObjectNode the returned set is a live unmodifiable view backed by the node's underlying map: subsequent put / remove on the same JsonNode.ObjectNode are visible through this view, and iterating it while another thread mutates the node will raise ConcurrentModificationException. If you need a stable snapshot or you intend to share the result across threads, copy it: Set.copyOf(node.keys()). Scalar nodes return an empty immutable set. 返回属性名(仅对对象有意义)。JsonNode.ObjectNode 返回的集合是底层 map 的不可变活视图: 后续在同一 JsonNode.ObjectNodeput/remove 会通过该视图体现; 在迭代过程中另一线程改动节点会抛 ConcurrentModificationException。 需要稳定快照或跨线程共享时,请用 Set.copyOf(node.keys()) 复制。 标量节点返回空的不可变集合。
      Specified by:
      keys in interface JsonNode
      Returns:
      the property names - 属性名
    • size

      public int size()
      Description copied from interface: JsonNode
      Returns the number of children (for objects/arrays). 返回子元素数量(用于对象/数组)。
      Specified by:
      size in interface JsonNode
      Returns:
      the size - 大小
    • put

      public JsonNode.ObjectNode put(String key, JsonNode value)
    • put

      public JsonNode.ObjectNode put(String key, String value)
    • put

      public JsonNode.ObjectNode put(String key, Number value)
    • put

      public JsonNode.ObjectNode put(String key, boolean value)
    • putNull

      public JsonNode.ObjectNode putNull(String key)
    • putObject

      public JsonNode.ObjectNode putObject(String key)
    • putArray

      public JsonNode.ArrayNode putArray(String key)
    • remove

      public JsonNode.ObjectNode remove(String key)
    • toMap

      public Map<String,JsonNode> toMap()
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object