java.io.Serializable
, java.lang.Iterable<java.util.Map.Entry<java.lang.String,JsonValueBase>>
public final class JsonObject extends JsonValueBase implements java.io.Serializable, java.lang.Iterable<java.util.Map.Entry<java.lang.String,JsonValueBase>>
Constructor | Description |
---|---|
JsonObject() |
Defafault constructor
|
JsonObject(java.lang.String json,
java.lang.String type) |
Overloaded constructor which populates attributes by parsing given JSONObject string.
|
Modifier and Type | Method | Description |
---|---|---|
void |
addAttribute(java.lang.String attributeName,
JsonValue attributeValue) |
Adds an attribute in the object.
|
void |
addAttribute(java.lang.String attributeName,
JsonValueBase attributeValue) |
Adds an attribute in the object.
|
void |
clear() |
Removes all attributes from JSONObject.
|
boolean |
containsAttribute(java.lang.String attributeName) |
Checks if the attribute exits.
|
boolean |
equals(java.lang.Object obj) |
Checks if an obj is equal to this instance of JSONObject
|
java.util.Collection<java.lang.String> |
getAttributeNames() |
Retruns collection of all the attribute names.
|
JsonValueBase |
getAttributeValue(java.lang.String attributeName) |
Gets attribute value identified by the attribute name.
|
int |
getCount() |
Gets the number of attributes in the json object.
|
JsonValueBase |
getItem(java.lang.String attributeName) |
Gets the value of the specified attribute in java object.
|
java.util.Iterator<java.util.Map.Entry<java.lang.String,JsonValueBase>> |
getIterator() |
Returns the
Iterator that iterates through JSONObject attributes. |
java.lang.String |
getType() |
Gets the type attribute of the json object.
|
java.lang.Object |
getValue() |
Gets the instance of the json object.
|
java.util.Iterator<java.util.Map.Entry<java.lang.String,JsonValueBase>> |
iterator() |
|
boolean |
removeAttribute(java.lang.String attributeName) |
Removes attribute from object on the basis of attribute name provided
|
void |
setItem(java.lang.String attributeName,
JsonValueBase value) |
Sets the value against the specified attribute name in the json object.
|
void |
setType(java.lang.String type) |
Sets the type attribute of the json object.
|
java.lang.String |
toString() |
Returns JSONObject in string representation.
|
getDataType, parse, toJson
public JsonObject()
public JsonObject(java.lang.String json, java.lang.String type)
json
- String representation of JSONObject.public JsonValueBase getItem(java.lang.String attributeName)
attributeName
- The name of the attribute.public java.util.Iterator<java.util.Map.Entry<java.lang.String,JsonValueBase>> iterator()
iterator
in interface java.lang.Iterable<java.util.Map.Entry<java.lang.String,JsonValueBase>>
public void setItem(java.lang.String attributeName, JsonValueBase value) throws OperationFailedException
attributeName
- The name of the attribute.value
- The value that is to be set against the attribute name.OperationFailedException
public int getCount()
public java.lang.Object getValue()
getValue
in class JsonValueBase
public void setType(java.lang.String type)
type
- The type attribute of the json object as string.public java.lang.String getType()
public java.util.Collection<java.lang.String> getAttributeNames()
public void addAttribute(java.lang.String attributeName, JsonValue attributeValue) throws OperationFailedException
attributeName
- Name of the attribute.attributeValue
- JSONValue as the attribute value.OperationFailedException
public void addAttribute(java.lang.String attributeName, JsonValueBase attributeValue) throws OperationFailedException
attributeName
- Name of the attribute.attributeValue
- JsonValueBase as the attribute value.OperationFailedException
public boolean removeAttribute(java.lang.String attributeName)
attributeName
- The name of the attribute that is to be removed.public JsonValueBase getAttributeValue(java.lang.String attributeName)
attributeName
- The name of the attribute.public boolean containsAttribute(java.lang.String attributeName)
attributeName
- The name of attribute.public void clear()
public java.util.Iterator<java.util.Map.Entry<java.lang.String,JsonValueBase>> getIterator()
Iterator
that iterates through JSONObject attributes.public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
obj
- The object that is to be compared with this object.public java.lang.String toString()
toString
in class java.lang.Object