JsonElement. This allows for a creating a
tree of JsonElements. The member elements of this object are maintained in order they were added.
This class does not support null values. If null is provided as value argument to
any of the methods, it is converted to a JsonNull.
JsonObject does not implement the Map interface, but a Map view of it
can be obtained with asMap().
See the JsonElement documentation for details on how to convert JsonObject and
generally any JsonElement from and to JSON.
| Modifier and Type | Field and Description |
|---|---|
| private final LinkedTreeMap |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | add(String
name of the member. property, JsonElement the member object. value)Adds a member, which is a name-value pair, to self. |
| public void | addProperty(String
name of the member. property, String the string value associated with the member. value)Convenience method to add a string member. |
| public void | addProperty(String
name of the member. property, Number the number value associated with the member. value)Convenience method to add a number member. |
| public void | addProperty(String
name of the member. property, Boolean the boolean value associated with the member. value)Convenience method to add a boolean member. |
| public void | addProperty(String
name of the member. property, Character the char value associated with the member. value)Convenience method to add a char member. |
| public Map | |
| public JsonObject | deepCopy()
Implements abstract com. Creates a deep copy of this element and all its children. |
| public Set | |
| public boolean | equals(Object o)
Overrides java. Returns whether the other object is equal to this. |
| public JsonElement | |
| public JsonArray | Returns: theJsonArray corresponding to the specified member, or null if no
member with this name exists.name of the member being requested. memberName)Convenience method to get the specified member as a |
| public JsonObject | Returns: theJsonObject corresponding to the specified member, or null if no
member with this name exists.name of the member being requested. memberName)Convenience method to get the specified member as a |
| public JsonPrimitive | Returns: theJsonPrimitive corresponding to the specified member, or null if no
member with this name exists.name of the member being requested. memberName)Convenience method to get the specified member as a |
| public boolean | |
| public int | |
| public boolean | Returns: true if the number of key/value pairs in the object is zero.Returns true if the number of key/value pairs in the object is zero. |
| public Set | |
| public JsonElement | |
| public int | Returns: the number of key/value pairs in the object.Returns the number of key/value pairs in the object. |
| members | back to summary |
|---|---|
| private final LinkedTreeMap<String, JsonElement> members | |
| JsonObject | back to summary |
|---|---|
| public JsonObject() Creates an empty JsonObject.
| |
| add | back to summary |
|---|---|
| public void add(String property, JsonElement value) Adds a member, which is a name-value pair, to self. The name must be a String, but the value
can be an arbitrary
| |
| addProperty | back to summary |
|---|---|
| public void addProperty(String property, String value) Convenience method to add a string member. The specified value is converted to a | |
| addProperty | back to summary |
|---|---|
| public void addProperty(String property, Number value) Convenience method to add a number member. The specified value is converted to a | |
| addProperty | back to summary |
|---|---|
| public void addProperty(String property, Boolean value) Convenience method to add a boolean member. The specified value is converted to a | |
| addProperty | back to summary |
|---|---|
| public void addProperty(String property, Character value) Convenience method to add a char member. The specified value is converted to a | |
| asMap | back to summary |
|---|---|
| public Map Returns a mutable The
| |
| deepCopy | back to summary |
|---|---|
| public JsonObject deepCopy() Implements abstract com. Creates a deep copy of this element and all its children.
| |
| entrySet | back to summary |
|---|---|
| public Set Returns a set of members of this object. The set is ordered, and the order is in which the elements were added.
| |
| equals | back to summary |
|---|---|
| public boolean equals(Object o) Overrides java. Returns whether the other object is equal to this. This method only considers the other object
to be equal if it is an instance of
| |
| get | back to summary |
|---|---|
| public JsonElement get(String memberName) Returns the member with the specified name.
| |
| getAsJsonArray | back to summary |
|---|---|
| public JsonArray getAsJsonArray(String memberName) Convenience method to get the specified member as a
| |
| getAsJsonObject | back to summary |
|---|---|
| public JsonObject getAsJsonObject(String memberName) Convenience method to get the specified member as a
| |
| getAsJsonPrimitive | back to summary |
|---|---|
| public JsonPrimitive getAsJsonPrimitive(String memberName) Convenience method to get the specified member as a
| |
| has | back to summary |
|---|---|
| public boolean has(String memberName) Convenience method to check if a member with the specified name is present in this object.
| |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Returns the hash code of this object. This method calculates the hash code based on the members of this object, ignoring order.
| |
| isEmpty | back to summary |
|---|---|
| public boolean isEmpty() Returns true if the number of key/value pairs in the object is zero.
| |
| keySet | back to summary |
|---|---|
| public Set Returns a set of members key values. | |
| remove | back to summary |
|---|---|
| public JsonElement remove(String property) Removes the
| |
| size | back to summary |
|---|---|
| public int size() Returns the number of key/value pairs in the object.
| |