Class JacksonObjectToJsonConverter

java.lang.Object
org.springframework.geode.data.json.converter.support.JacksonObjectToJsonConverter
All Implemented Interfaces:
org.springframework.core.convert.converter.Converter<Object,String>, ObjectToJsonConverter
Direct Known Subclasses:
JSONFormatterPdxToJsonConverter

public class JacksonObjectToJsonConverter extends Object implements ObjectToJsonConverter
A ObjectToJsonConverter implementation using Jackson's ObjectMapper to convert from an Object to a JSON String.
Since:
1.3.0
See Also:
  • Field Details

  • Constructor Details

    • JacksonObjectToJsonConverter

      public JacksonObjectToJsonConverter()
  • Method Details

    • convert

      @NonNull public String convert(@NonNull Object source)
      Converts the given Object into JSON.
      Specified by:
      convert in interface org.springframework.core.convert.converter.Converter<Object,String>
      Parameters:
      source - Object to convert into JSON.
      Returns:
      JSON generated from the given Object using Jackson's ObjectMapper.
      Throws:
      IllegalArgumentException - if source is null.
      org.springframework.core.convert.ConversionFailedException - if a JsonProcessingException is thrown or another error occurs while trying to convert the given Object to JSON.
      See Also:
    • convertObjectToJson

      @NonNull protected String convertObjectToJson(@NonNull Object source) throws com.fasterxml.jackson.core.JsonProcessingException
      Converts the given Object into JSON.
      Parameters:
      source - Object to convert to JSON; must not be null.
      Returns:
      JSON generated from the given Object.
      Throws:
      IllegalArgumentException - if source is null.
      com.fasterxml.jackson.core.JsonProcessingException - if the generation of JSON from the given Object results in an error.
      See Also:
    • newObjectMapper

      @NonNull protected com.fasterxml.jackson.databind.ObjectMapper newObjectMapper(@NonNull Object target)
      Constructs a new instance of the Jackson ObjectMapper class.
      Returns:
      a new instance of the Jackson ObjectMapper class.
      See Also:
      • ObjectMapper