JsonSerializable Class
- java.
lang. Object - Serializable
- com.
microsoft. azure. documentdb. JsonSerializable
- com.
public class JsonSerializable
Represents a base resource that can be serialized to JSON in the Azure Cosmos DB database service.
Note on Serializable: this interface is implemented solely for the use with the CosmosDB Spark Connector. In RDD transformation, it is a requirement of the RDD item type to be Serializable so that they can be transferred among the work nodes by the default serializer. The Serializable is not intended to be used by the user of the Cosmos DB Java SDK. Avoid relying on the serialized string format as it can change in the future.
Constructor Summary
Constructor | Description | |
---|---|---|
JsonSerializable() | ||
JsonSerializable(JSONObject jsonObject) |
Constructor. |
|
JsonSerializable(String jsonString) |
Constructor. |
|
JsonSerializable(String jsonString, ObjectMapper objectMapper) |
Constructor. |
Method Summary
Modifier and Type | Method and Description |
---|---|
Object |
get(String propertyName)
Gets a property value as Object. |
Boolean |
getBoolean(String propertyName)
Gets a boolean value. |
Collection<JSONObject> |
getCollection(String propertyName)
Gets a JSONObject collection. |
<T extends Object> Collection<T> |
getCollection(String propertyName, Class<T> c)
Gets an object collection. |
Double |
getDouble(String propertyName)
Gets a double value. |
HashMap<String, Object> |
getHashMap()
Returns the propertybag(JSONObject) in a hashMap |
Integer |
getInt(String propertyName)
Gets an integer value. |
Logger | getLogger() |
Long |
getLong(String propertyName)
Gets a long value. |
ObjectMapper | getMapper() |
JSONObject |
getObject(String propertyName)
Gets a JSONObject. |
<T extends Object> T |
getObject(String propertyName, Class<T> c)
Gets an object value. |
Object |
getObjectByPath(Collection<String> propertyNames)
Gets the value of a property identified by an array of property names that forms the path. |
String |
getString(String propertyName)
Gets a string value. |
boolean |
has(String propertyName)
Checks whether a property exists. |
void |
remove(String propertyName)
Removes a value by propertyName. |
<T extends Object> void |
set(String propertyName, T value)
Sets the value of a property. |
String |
toJson()
Converts to a JSON string. |
String |
toJson(SerializationFormattingPolicy formattingPolicy)
Converts to a JSON string. |
<T extends Object> T |
toObject(Class<T> c)
Converts to an Object (only POJOs and JSONObject are supported). |
String |
toString()
Gets Simple String representation of property bag. For proper conversion to json and inclusion of the default values use toJson(). |
String |
toString(int indentFactor)
Gets formatted String representation of property bag.
|
Constructor Details
JsonSerializable
protected JsonSerializable()
JsonSerializable
protected JsonSerializable(JSONObject jsonObject)
Constructor.
Parameters:
JsonSerializable
protected JsonSerializable(String jsonString)
Constructor.
Parameters:
JsonSerializable
protected JsonSerializable(String jsonString, ObjectMapper objectMapper)
Constructor.
Parameters:
Method Details
get
public Object get(String propertyName)
Gets a property value as Object.
Parameters:
Returns:
getBoolean
public Boolean getBoolean(String propertyName)
Gets a boolean value.
Parameters:
Returns:
getCollection
public Collection
Gets a JSONObject collection.
Parameters:
Returns:
getCollection
public
Gets an object collection.
Parameters:
Returns:
getDouble
public Double getDouble(String propertyName)
Gets a double value.
Parameters:
Returns:
getHashMap
public HashMap
Returns the propertybag(JSONObject) in a hashMap
Returns:
getInt
public Integer getInt(String propertyName)
Gets an integer value.
Parameters:
Returns:
getLogger
protected Logger getLogger()
getLong
public Long getLong(String propertyName)
Gets a long value.
Parameters:
Returns:
getMapper
protected ObjectMapper getMapper()
getObject
public JSONObject getObject(String propertyName)
Gets a JSONObject.
Parameters:
Returns:
getObject
public
Gets an object value.
Parameters:
Returns:
getObjectByPath
public Object getObjectByPath(Collection
Gets the value of a property identified by an array of property names that forms the path.
Parameters:
Returns:
getString
public String getString(String propertyName)
Gets a string value.
Parameters:
Returns:
has
public boolean has(String propertyName)
Checks whether a property exists.
Parameters:
Returns:
remove
public void remove(String propertyName)
Removes a value by propertyName.
Parameters:
set
public
Sets the value of a property.
Parameters:
toJson
public String toJson()
Converts to a JSON string.
Returns:
toJson
public String toJson(SerializationFormattingPolicy formattingPolicy)
Converts to a JSON string.
Parameters:
Returns:
toObject
public
Converts to an Object (only POJOs and JSONObject are supported).
Parameters:
Returns:
toString
public String toString()
Gets Simple String representation of property bag.
For proper conversion to json and inclusion of the default values use toJson().
Returns:
toString
public String toString(int indentFactor)
Gets formatted String representation of property bag.
<xreftitle>Deprecated</xreftitle>
<xrefdescription>
<p>For proper conversion to json and inclusion of the default values use <xref uid="com.microsoft.azure.documentdb.JsonSerializable.toJson(SerializationFormattingPolicy)" data-throw-if-not-resolved="false" data-raw-source="toJson(SerializationFormattingPolicy)"></xref>.</p>
</xrefdescription>
Parameters:
Returns:
Applies to
Azure SDK for Java