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
(org.bson.Document source) Flattens out a givenDocument
.static String
serializeToJsonSafely
(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 String
serializeValue
(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
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 rawDocument
s containing complex values before actually converting them into Mongo native types.- Parameters:
value
-- Returns:
- the serialized value or null.
-
serializeValue
-