Class JacksonMediaTypeCodec

  • All Implemented Interfaces:
    io.micronaut.http.codec.MediaTypeCodec
    Direct Known Subclasses:
    JsonMediaTypeCodec

    public abstract class JacksonMediaTypeCodec
    extends io.micronaut.json.codec.MapperMediaTypeCodec
    A MediaTypeCodec for JSON and Jackson. Note: will be replaced by MapperMediaTypeCodec in the future, but that class is currently experimental.
    Since:
    1.0.0
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String REGULAR_JSON_MEDIA_TYPE_CODEC_NAME  
      • Fields inherited from class io.micronaut.json.codec.MapperMediaTypeCodec

        additionalTypes, applicationConfiguration, codecConfiguration, mediaType
    • Constructor Summary

      Constructors 
      Constructor Description
      JacksonMediaTypeCodec​(com.fasterxml.jackson.databind.ObjectMapper objectMapper, io.micronaut.runtime.ApplicationConfiguration applicationConfiguration, io.micronaut.http.codec.CodecConfiguration codecConfiguration, io.micronaut.http.MediaType mediaType)  
      JacksonMediaTypeCodec​(io.micronaut.context.BeanProvider<com.fasterxml.jackson.databind.ObjectMapper> objectMapperProvider, io.micronaut.runtime.ApplicationConfiguration applicationConfiguration, io.micronaut.http.codec.CodecConfiguration codecConfiguration, io.micronaut.http.MediaType mediaType)  
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      abstract JacksonMediaTypeCodec cloneWithFeatures​(JacksonFeatures jacksonFeatures)
      Create a new codec with the provided features.
      io.micronaut.json.codec.MapperMediaTypeCodec cloneWithFeatures​(io.micronaut.json.JsonFeatures features)  
      protected io.micronaut.json.codec.MapperMediaTypeCodec cloneWithMapper​(io.micronaut.json.JsonMapper mapper)  
      <T> T decode​(io.micronaut.core.type.Argument<T> type, com.fasterxml.jackson.databind.JsonNode node)
      Decodes the given JSON node.
      com.fasterxml.jackson.databind.ObjectMapper getObjectMapper()  
      • Methods inherited from class io.micronaut.json.codec.MapperMediaTypeCodec

        cloneWithViewClass, decode, decode, decode, decode, decode, encode, encode, encode, encode, encode, encode, getJsonMapper, getMediaTypes, supportsType
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface io.micronaut.http.codec.MediaTypeCodec

        decode, decode, decode, decode
    • Field Detail

      • REGULAR_JSON_MEDIA_TYPE_CODEC_NAME

        public static final java.lang.String REGULAR_JSON_MEDIA_TYPE_CODEC_NAME
        See Also:
        Constant Field Values
    • Constructor Detail

      • JacksonMediaTypeCodec

        public JacksonMediaTypeCodec​(io.micronaut.context.BeanProvider<com.fasterxml.jackson.databind.ObjectMapper> objectMapperProvider,
                                     io.micronaut.runtime.ApplicationConfiguration applicationConfiguration,
                                     io.micronaut.http.codec.CodecConfiguration codecConfiguration,
                                     io.micronaut.http.MediaType mediaType)
      • JacksonMediaTypeCodec

        public JacksonMediaTypeCodec​(com.fasterxml.jackson.databind.ObjectMapper objectMapper,
                                     io.micronaut.runtime.ApplicationConfiguration applicationConfiguration,
                                     io.micronaut.http.codec.CodecConfiguration codecConfiguration,
                                     io.micronaut.http.MediaType mediaType)
    • Method Detail

      • getObjectMapper

        public com.fasterxml.jackson.databind.ObjectMapper getObjectMapper()
        Returns:
        The object mapper
      • cloneWithFeatures

        public io.micronaut.json.codec.MapperMediaTypeCodec cloneWithFeatures​(io.micronaut.json.JsonFeatures features)
        Overrides:
        cloneWithFeatures in class io.micronaut.json.codec.MapperMediaTypeCodec
      • cloneWithFeatures

        public abstract JacksonMediaTypeCodec cloneWithFeatures​(JacksonFeatures jacksonFeatures)
        Create a new codec with the provided features.
        Parameters:
        jacksonFeatures - The jackson features
        Returns:
        The new codec
      • cloneWithMapper

        protected io.micronaut.json.codec.MapperMediaTypeCodec cloneWithMapper​(io.micronaut.json.JsonMapper mapper)
        Specified by:
        cloneWithMapper in class io.micronaut.json.codec.MapperMediaTypeCodec
      • decode

        public <T> T decode​(io.micronaut.core.type.Argument<T> type,
                            com.fasterxml.jackson.databind.JsonNode node)
                     throws io.micronaut.http.codec.CodecException
        Decodes the given JSON node.
        Type Parameters:
        T - The generic type
        Parameters:
        type - The type
        node - The Json Node
        Returns:
        The decoded object
        Throws:
        io.micronaut.http.codec.CodecException - When object cannot be decoded