Class JacksonJsonEncoder

java.lang.Object
org.springframework.http.codec.JacksonCodecsupport<tools.jackson.databind.json.JsonMapper>
org.springframework.http.codec.AbstractJacksonEncoder<tools.jackson.databind.json.JsonMapper>
org.springframework.http.codec.json.JacksonJsonEncoder
All Implemented Interfaces:
Encoder<Object>, HttpMessageEncoder<Object>

public class JacksonJsonEncoder extends AbstractJacksonEncoder<tools.jackson.databind.json.JsonMapper>
Encode from an Object stream to a byte stream of JsON objects using Jackson 3.x. For non-streaming use cases, Flux elements are collected into a List before serialization for performance reason.
since:
7.0
Author:
sebastien Deleuze
see Also:
  • Constructor Details

    • JacksonJsonEncoder

      public&nbsp;JacksonJsonEncoder()
      Construct a new instance with a JsonMapper customized with the JacksonModules found by MapperBuilder.findModules(ClassLoader) and ProblemDetailJacksonMixin.
    • JacksonJsonEncoder

      public&nbsp;JacksonJsonEncoder(tools.jackson.databind.json.JsonMapper.Builder&nbsp;builder)
      Construct a new instance with a JsonMapper.Builder customized with the JacksonModules found by MapperBuilder.findModules(ClassLoader) and ProblemDetailJacksonMixin.
      see Also:
      • JsonMapper.builder()
    • JacksonJsonEncoder

      public&nbsp;JacksonJsonEncoder(tools.jackson.databind.json.JsonMapper&nbsp;mapper)
      Construct a new instance with the provided JsonMapper.
    • JacksonJsonEncoder

      public&nbsp;JacksonJsonEncoder(tools.jackson.databind.json.JsonMapper.Builder&nbsp;builder, MimeType...&nbsp;mimeTypes)
      Construct a new instance with the provided JsonMapper.Builder customized with the JacksonModules found by MapperBuilder.findModules(ClassLoader) and ProblemDetailJacksonMixin, and MimeTypes.
      see Also:
      • JsonMapper.builder()
    • JacksonJsonEncoder

      public&nbsp;JacksonJsonEncoder(tools.jackson.databind.json.JsonMapper&nbsp;mapper, MimeType...&nbsp;mimeTypes)
      Construct a new instance with the provided JsonMapper and MimeTypes.
      see Also:
      • JsonMapper.builder()
  • Method Details

    • getMediaTypesForProblemDetail

      protected&nbsp;List<MimeType>&nbsp;getMediaTypesForProblemDetail()
      Description copied from class:&nbsp;JacksonCodecsupport
      Return the supported media type(s) for ProblemDetail. By default, an empty list, unless overridden in subclasses.
      Overrides:
      getMediaTypesForProblemDetail&nbsp;in class&nbsp;JacksonCodecsupport<tools.jackson.databind.json.JsonMapper>
    • customizeWriter

      protected&nbsp;tools.jackson.databind.ObjectWriter&nbsp;customizeWriter(tools.jackson.databind.ObjectWriter&nbsp;writer, @Nullable MimeType&nbsp;mimeType, ResolvableType&nbsp;elementType, @Nullable Map<string,Object>&nbsp;hints)
      Description copied from class:&nbsp;AbstractJacksonEncoder
      subclasses can use this method to customize the ObjectWriter used for writing values.
      Overrides:
      customizeWriter&nbsp;in class&nbsp;AbstractJacksonEncoder<tools.jackson.databind.json.JsonMapper>
      Parameters:
      writer - the writer instance to customize
      mimeType - the selected MIME type
      elementType - the type of element values to write
      hints - a map with serialization hints; the Reactor Context, when available, may be accessed under the key ContextView.class.getName()
      Returns:
      the customized ObjectWriter to use