Interface ObjectMapper

All Superinterfaces:
io.micronaut.json.JsonMapper
All Known Subinterfaces:
JacksonObjectMapper, ObjectMapper.CloseableObjectMapper
All Known Implementing Classes:
AbstractBsonMapper, BsonBinaryMapper, BsonJsonMapper, JacksonJsonMapper, JsonStreamMapper, OracleJdbcJsonBinaryObjectMapper, OracleJdbcJsonTextObjectMapper

public interface ObjectMapper extends io.micronaut.json.JsonMapper
Sub-interface of JsonMapper with customizations.
Author:
graemerocher
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static interface 
    A closeable object mapper.
  • Method Summary

    Modifier and Type
    Method
    Description
    default @NonNull ObjectMapper
    cloneWithConfiguration(@Nullable SerdeConfiguration configuration, @Nullable SerializationConfiguration serializationConfiguration, @Nullable DeserializationConfiguration deserializationConfiguration)
    Optional feature.
    default io.micronaut.json.JsonMapper
    cloneWithFeatures(io.micronaut.json.JsonFeatures features)
     
    create(Map<String,Object> configuration, String... packageNames)
    Creates a new custom ObjectMapper with additional beans (serializers, deserializers etc.) loaded from the given package locations.
    static @NonNull ObjectMapper
    Get the default ObjectMapper instance.
    default @NonNull String
    writeValueAsString(@NonNull Object object)
     

    Methods inherited from interface io.micronaut.json.JsonMapper

    cloneWithViewClass, createReactiveParser, createSpecific, detectFeatures, getStreamConfig, readValue, readValue, readValue, readValue, readValue, readValue, readValue, readValueFromTree, readValueFromTree, updateValueFromTree, writeValue, writeValue, writeValueAsBytes, writeValueAsBytes, writeValueAsString, writeValueAsString, writeValueToTree, writeValueToTree
  • Method Details

    • writeValueAsString

      @NonNull default @NonNull String writeValueAsString(@NonNull @NonNull Object object) throws IOException
      Specified by:
      writeValueAsString in interface io.micronaut.json.JsonMapper
      Throws:
      IOException
    • cloneWithFeatures

      default io.micronaut.json.JsonMapper cloneWithFeatures(io.micronaut.json.JsonFeatures features)
      Specified by:
      cloneWithFeatures in interface io.micronaut.json.JsonMapper
    • cloneWithConfiguration

      @NonNull default @NonNull ObjectMapper cloneWithConfiguration(@Nullable @Nullable SerdeConfiguration configuration, @Nullable @Nullable SerializationConfiguration serializationConfiguration, @Nullable @Nullable DeserializationConfiguration deserializationConfiguration)
      Optional feature. Create a new ObjectMapper with the given configuration values. A null parameter indicates the old configuration should be used.
      Parameters:
      configuration - The SerdeConfiguration
      serializationConfiguration - The SerializationConfiguration
      deserializationConfiguration - The DeserializationConfiguration
      Returns:
      A new JsonMapper with the updated config
      Since:
      2.7.0
    • getDefault

      @NonNull static @NonNull ObjectMapper getDefault()
      Get the default ObjectMapper instance.

      Note that this method returns an ObjectMapper that does not include any custom defined serializers or deserializers and in general should be avoided outside a few niche cases that require static access.

      Where possible you should use dependency injection to instead retrieve the ObjectMapper from the application context.

      Returns:
      The default object mapper
      Since:
      1.3.0
    • create

      @NonNull static @NonNull ObjectMapper.CloseableObjectMapper create(Map<String,Object> configuration, String... packageNames)
      Creates a new custom ObjectMapper with additional beans (serializers, deserializers etc.) loaded from the given package locations.
      Parameters:
      configuration - The configuration
      packageNames - The package names
      Returns:
      The new object mapper
      Since:
      1.5.1