Package de.otto.synapse.translator
Class JsonHelper
java.lang.Object
de.otto.synapse.translator.JsonHelper
Helper-class for JSON representations.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringprettyPrint(Object entity) Transforms the given entity into a pretty-printed JSON representation.static StringprettyPrint(String json) Pretty-prints the given json document into.
-
Constructor Details
-
JsonHelper
public JsonHelper()
-
-
Method Details
-
prettyPrint
Transforms the given entity into a pretty-printed JSON representation.The
ObjectMappers.currentObjectMapper()is used to serialize the entity.- Parameters:
entity- some json-serializable object- Returns:
- pretty-printed JSON, or "null" if entity is null.
- Throws:
IllegalStateException- if serializing the entity fails for some reason.
-
prettyPrint
Pretty-prints the given json document into.- Parameters:
json- the json document- Returns:
- pretty-printed JSON.
- Throws:
IllegalStateException- if serializing the entity fails for some reason.
-