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
  • 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
    • getSerdeRegistry

      @NonNull default @NonNull SerdeRegistry getSerdeRegistry()
      Returns the SerdeRegistry used by this object mapper, if possible.
      Returns:
      The serde registry
    • 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