Class JsonHelper


  • public class JsonHelper
    extends java.lang.Object
    Helper-class for JSON representations.
    • Constructor Summary

      Constructors 
      Constructor Description
      JsonHelper()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String prettyPrint​(java.lang.Object entity)
      Transforms the given entity into a pretty-printed JSON representation.
      static java.lang.String prettyPrint​(java.lang.String json)
      Pretty-prints the given json document into.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • JsonHelper

        public JsonHelper()
    • Method Detail

      • prettyPrint

        public static java.lang.String prettyPrint​(java.lang.Object entity)
        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:
        java.lang.IllegalStateException - if serializing the entity fails for some reason.
      • prettyPrint

        public static java.lang.String prettyPrint​(java.lang.String json)
        Pretty-prints the given json document into.
        Parameters:
        json - the json document
        Returns:
        pretty-printed JSON.
        Throws:
        java.lang.IllegalStateException - if serializing the entity fails for some reason.