你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。
JsonSerializable Class
- java.
lang. Object - com.
microsoft. azure. documentdb. JsonSerializable
- com.
Implements
public class JsonSerializable
implements java.io.Serializable
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
Modifier | Constructor | Description | |
---|---|---|---|
protected | JsonSerializable() | ||
protected | JsonSerializable(String jsonString) |
Constructor. |
|
protected | JsonSerializable(String jsonString, ObjectMapper objectMapper) |
Constructor. |
|
protected | JsonSerializable(JSONObject jsonObject) |
Constructor. |
Method Summary
Modifier and Type | Method and Description |
---|---|
java.util.Collection<T> |
getCollection(String propertyName, Class<T> c)
Gets an object collection. |
T |
getObject(String propertyName, Class<T> c)
Gets an object value. |
void |
set(String propertyName, T value)
Sets the value of a property. |
T |
toObject(Class<T> c)
Converts to an Object (only POJOs and JSONObject are supported). |
java.lang.Object |
get(String propertyName)
Gets a property value as Object. |
java.lang.Boolean |
getBoolean(String propertyName)
Gets a boolean value. |
java.util.Collection<org.json.JSONObject> |
getCollection(String propertyName)
Gets a JSONObject collection. |
java.lang.Double |
getDouble(String propertyName)
Gets a double value. |
java.util.HashMap<java.lang.String,java.lang.Object> |
getHashMap()
Returns the propertybag(JSONObject) in a hash |
java.lang.Integer |
getInt(String propertyName)
Gets an integer value. |
protected org.slf4j.Logger | getLogger() |
java.lang.Long |
getLong(String propertyName)
Gets a long value. |
protected com.fasterxml.jackson.databind.ObjectMapper | getMapper() |
org.json.JSONObject |
getObject(String propertyName)
Gets a JSONObject. |
java.lang.Object |
getObjectByPath(Collection<String> propertyNames)
Gets the value of a property identified by an array of property names that forms the path. |
java.lang.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 property |
java.lang.String |
toJson()
Converts to a JSON string. |
java.lang.String |
toJson(SerializationFormattingPolicy formattingPolicy)
Converts to a JSON string. |
java.lang.String |
toString()
Gets Simple String representation of property bag. |
java.lang.String |
toString(int indentFactor)
Deprecated
For proper conversion to json and inclusion of the default values use toJson(SerializationFormattingPolicy formattingPolicy).
Gets formatted String representation of property bag. |
Methods inherited from java.lang.Object
Constructor Details
JsonSerializable
protected JsonSerializable()
JsonSerializable
protected JsonSerializable(String jsonString)
Constructor.
Parameters:
JsonSerializable
protected JsonSerializable(String jsonString, ObjectMapper objectMapper)
Constructor.
Parameters:
JsonSerializable
protected JsonSerializable(JSONObject jsonObject)
Constructor.
Parameters:
Method Details
getCollection
public Collection
Gets an object collection.
Parameters:
Returns:
getObject
public T
Gets an object value.
Parameters:
Returns:
set
public void
Sets the value of a property.
Parameters:
toObject
public T
Converts to an Object (only POJOs and JSONObject are supported).
Parameters:
Returns:
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:
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:
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:
toJson
public String toJson()
Converts to a JSON string.
Returns:
toJson
public String toJson(SerializationFormattingPolicy formattingPolicy)
Converts to a JSON string.
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().
Overrides:
JsonSerializable.toString()Returns:
toString
public String toString(int indentFactor)
Deprecated
Gets formatted String representation of property bag.
Parameters:
Returns: