Class JacksonBasedJsonEngine


public abstract class JacksonBasedJsonEngine extends JsonEngine
GSON-based implementation of JsonEngine.
  • Constructor Details

    • JacksonBasedJsonEngine

      public JacksonBasedJsonEngine()
      Creates a new JSON engine with standard converters registered.
  • Method Details

    • deserialize

      public Object deserialize(Reader source, Type type) throws JsonDeserializationException
      Specified by:
      deserialize in class JsonEngine
      Throws:
      JsonDeserializationException
    • writeTo

      public void writeTo(Object value, Writer destination) throws JsonSerializationException
      Specified by:
      writeTo in class JsonEngine
      Throws:
      JsonSerializationException
    • readJson

      protected abstract com.fasterxml.jackson.databind.JsonNode readJson(Reader source) throws JsonDeserializationException
      Reads JSON syntax from the specified source.
      Parameters:
      source - the source to read from
      Returns:
      the JSON tree
      Throws:
      JsonDeserializationException - on errors
    • writeJson

      protected abstract void writeJson(com.fasterxml.jackson.databind.JsonNode json, Writer destination) throws JsonSerializationException
      Writes JSON syntax to the specified destination.
      Parameters:
      json - the JSON tree
      destination - the destination to write to
      Throws:
      JsonSerializationException - on errors
    • fromObjectMapper

      public static JacksonBasedJsonEngine fromObjectMapper(com.fasterxml.jackson.databind.ObjectMapper objectMapper)
      Creates a new JSON engine that uses the specified Jackson ObjectMapper for JSON syntax processing.
      Parameters:
      objectMapper - used for reading and writing JSON syntax
      Returns:
      the JSON engine
    • fromObjectReaderAndWriter

      public static JacksonBasedJsonEngine fromObjectReaderAndWriter(com.fasterxml.jackson.databind.ObjectReader objectReader, com.fasterxml.jackson.databind.ObjectWriter objectWriter)
      Creates a new JSON engine that uses the specified Jackson ObjectReader and ObjectWriter for JSON syntax processing.
      Parameters:
      objectReader - used for reading JSON syntax
      objectWriter - used for writing JSON syntax
      Returns:
      the JSON engine
    • fromObjectReader

      public static JacksonBasedJsonEngine fromObjectReader(com.fasterxml.jackson.databind.ObjectReader objectReader)
      Creates a new read-only JSON engine that uses the specified Jackson ObjectReader for JSON syntax processing.
      Parameters:
      objectReader - used for reading JSON syntax
      Returns:
      the read-only JSON engine
    • fromObjectWriter

      public static JacksonBasedJsonEngine fromObjectWriter(com.fasterxml.jackson.databind.ObjectWriter objectWriter)
      Creates a new write-only JSON engine that uses the specified Jackson ObjectWriter for JSON syntax processing.
      Parameters:
      objectWriter - used for writing JSON syntax
      Returns:
      the write-only JSON engine