Package io.micronaut.serde
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
Modifier and TypeInterfaceDescriptionstatic interface
A closeable object mapper. -
Method Summary
Modifier and TypeMethodDescriptiondefault @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) static @NonNull ObjectMapper.CloseableObjectMapper
Creates a new customObjectMapper
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 interfaceio.micronaut.json.JsonMapper
- Throws:
IOException
-
cloneWithFeatures
default io.micronaut.json.JsonMapper cloneWithFeatures(io.micronaut.json.JsonFeatures features) - Specified by:
cloneWithFeatures
in interfaceio.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 newObjectMapper
with the given configuration values. Anull
parameter indicates the old configuration should be used.- Parameters:
configuration
- TheSerdeConfiguration
serializationConfiguration
- TheSerializationConfiguration
deserializationConfiguration
- TheDeserializationConfiguration
- Returns:
- A new
JsonMapper
with the updated config - Since:
- 2.7.0
-
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 customObjectMapper
with additional beans (serializers, deserializers etc.) loaded from the given package locations.- Parameters:
configuration
- The configurationpackageNames
- The package names- Returns:
- The new object mapper
- Since:
- 1.5.1
-