Class JsonPrintFormat<T>

java.lang.Object
org.approvej.json.jackson.JsonPrintFormat<T>
Type Parameters:
T - the type of the object to print
All Implemented Interfaces:
org.approvej.print.PrintFormat<T>

@NullMarked public final class JsonPrintFormat<T> extends Object implements org.approvej.print.PrintFormat<T>
A PrintFormat that uses ObjectWriter.writeValueAsString(Object) to print a value as JSON.
  • Constructor Details

    • JsonPrintFormat

      public JsonPrintFormat()
      Default constructor to be used in Configuration.
  • Method Details

    • printer

      public org.approvej.print.Printer<T> printer()
      Specified by:
      printer in interface org.approvej.print.PrintFormat<T>
    • filenameExtension

      public String filenameExtension()
      Specified by:
      filenameExtension in interface org.approvej.print.PrintFormat<T>
    • json

      public static <T> JsonPrintFormat<T> json(com.fasterxml.jackson.databind.ObjectMapper objectMapper)
      Creates a JsonPrintFormat using the given ObjectMapper.
      Type Parameters:
      T - the type of value to print
      Parameters:
      objectMapper - the ObjectMapper used to create the ObjectWriter
      Returns:
      a new JsonPrintFormat instance
      See Also:
      • ObjectMapper.writerWithDefaultPrettyPrinter()
    • json

      public static <T> JsonPrintFormat<T> json()
      Creates a JsonPrintFormat using the default JsonMapper.
      Type Parameters:
      T - the type of value to print
      Returns:
      a new JsonPrintFormat instance
      See Also:
      • MapperBuilder.build()