Class SerializationUtils
java.lang.Object
org.springframework.data.mongodb.core.query.SerializationUtils
Utility methods for JSON serialization.
- Author:
- Oliver Gierke, Christoph Strobl, Mark Paluch
-
Method Summary
Modifier and TypeMethodDescriptionflattenMap(@Nullable org.bson.Document source) Flattens out a givenDocument.static @Nullable StringserializeToJsonSafely(@Nullable Object value) Serializes the given object into pseudo-JSON meaning it's trying to create a JSON representation as far as possible but falling back to the given object'sObject.toString()method if it's not serializable.static StringserializeValue(@Nullable Object value)
-
Method Details
-
flattenMap
Flattens out a givenDocument.{ _id : 1 nested : { value : "conflux"} }will result in{ _id : 1 nested.value : "conflux" }- Parameters:
source- can be null.- Returns:
Collections.emptyMap()when source is null- Since:
- 1.8
-
serializeToJsonSafely
@Contract("null -> null; !null -> !null") public static @Nullable String serializeToJsonSafely(@Nullable Object value) Serializes the given object into pseudo-JSON meaning it's trying to create a JSON representation as far as possible but falling back to the given object'sObject.toString()method if it's not serializable. Useful for printing rawDocuments containing complex values before actually converting them into Mongo native types.- Parameters:
value-- Returns:
- the serialized value or null.
-
serializeValue
-