@Internal @Singleton public final class JacksonDatabindMapper extends Object implements JsonMapper
JsonMapper.| Constructor and Description |
|---|
JacksonDatabindMapper() |
JacksonDatabindMapper(com.fasterxml.jackson.databind.ObjectMapper objectMapper) |
| Modifier and Type | Method and Description |
|---|---|
JsonMapper |
cloneWithFeatures(JsonFeatures features)
Create a copy of this mapper with the given json features as returned by
JsonMapper.detectFeatures(io.micronaut.core.annotation.AnnotationMetadata). |
JsonMapper |
cloneWithViewClass(Class<?> viewClass)
Create a copy of this mapper with the given view class.
|
Processor<byte[],JsonNode> |
createReactiveParser(Consumer<Processor<byte[],JsonNode>> onSubscribe,
boolean streamArray)
|
Optional<JsonFeatures> |
detectFeatures(AnnotationMetadata annotations)
Detect
JsonFeatures from the given annotation data. |
com.fasterxml.jackson.databind.ObjectMapper |
getObjectMapper() |
JsonStreamConfig |
getStreamConfig() |
<T> T |
readValue(byte[] byteArray,
Argument<T> type)
Parse and map json from the given byte array.
|
<T> T |
readValue(InputStream inputStream,
Argument<T> type)
Parse and map json from the given stream.
|
<T> T |
readValueFromTree(JsonNode tree,
Argument<T> type)
Transform a
JsonNode to a value of the given type. |
void |
updateValueFromTree(Object value,
JsonNode tree)
Update an object from json data.
|
<T> void |
writeValue(OutputStream outputStream,
Argument<T> type,
T object)
Write an object as json.
|
void |
writeValue(OutputStream outputStream,
Object object)
Write an object as json.
|
<T> byte[] |
writeValueAsBytes(Argument<T> type,
T object)
Write an object as json.
|
byte[] |
writeValueAsBytes(Object object)
Write an object as json.
|
<T> JsonNode |
writeValueToTree(Argument<T> type,
T value)
Transform an object value to a json tree.
|
JsonNode |
writeValueToTree(Object value)
Transform an object value to a json tree.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitreadValue, readValueFromTree@Inject @Internal public JacksonDatabindMapper(com.fasterxml.jackson.databind.ObjectMapper objectMapper)
@Internal public JacksonDatabindMapper()
@Internal public com.fasterxml.jackson.databind.ObjectMapper getObjectMapper()
public <T> T readValueFromTree(@NonNull JsonNode tree, @NonNull Argument<T> type) throws IOException
JsonMapperJsonNode to a value of the given type.readValueFromTree in interface JsonMapperT - Type variable of the return type.tree - The input json data.type - The type to deserialize.IOException@NonNull public JsonNode writeValueToTree(@Nullable Object value) throws IOException
JsonMapperwriteValueToTree in interface JsonMappervalue - The object value to transform.IOException - If there are any mapping exceptions (e.g. illegal values).@NonNull public <T> JsonNode writeValueToTree(@NonNull Argument<T> type, T value) throws IOException
JsonMapperwriteValueToTree in interface JsonMapperT - The type variable of the type.type - The object typevalue - The object value to transform.IOException - If there are any mapping exceptions (e.g. illegal values).public <T> T readValue(@NonNull InputStream inputStream, @NonNull Argument<T> type) throws IOException
JsonMapperreadValue in interface JsonMapperT - Type variable of the return type.inputStream - The input data.type - The type to deserialize to.IOExceptionpublic <T> T readValue(@NonNull byte[] byteArray, @NonNull Argument<T> type) throws IOException
JsonMapperreadValue in interface JsonMapperT - Type variable of the return type.byteArray - The input data.type - The type to deserialize to.IOExceptionpublic void writeValue(@NonNull OutputStream outputStream, @Nullable Object object) throws IOException
JsonMapperwriteValue in interface JsonMapperoutputStream - The stream to write to.object - The object to serialize.IOExceptionpublic <T> void writeValue(@NonNull OutputStream outputStream, @NonNull Argument<T> type, T object) throws IOException
JsonMapperwriteValue in interface JsonMapperT - The generic typeoutputStream - The stream to write to.type - The object typeobject - The object to serialize.IOExceptionpublic byte[] writeValueAsBytes(@Nullable Object object) throws IOException
JsonMapperwriteValueAsBytes in interface JsonMapperobject - The object to serialize.IOExceptionpublic <T> byte[] writeValueAsBytes(@NonNull Argument<T> type, T object) throws IOException
JsonMapperwriteValueAsBytes in interface JsonMapperT - The generidc typetype - The object typeobject - The object to serialize.IOExceptionpublic void updateValueFromTree(Object value, @NonNull JsonNode tree) throws IOException
JsonMapperupdateValueFromTree in interface JsonMappervalue - The object to update.tree - The json data to update from.IOException - If there are any mapping exceptions (e.g. illegal values).@NonNull public JsonMapper cloneWithFeatures(@NonNull JsonFeatures features)
JsonMapperJsonMapper.detectFeatures(io.micronaut.core.annotation.AnnotationMetadata).cloneWithFeatures in interface JsonMapperfeatures - The json features to configure.@NonNull public JsonMapper cloneWithViewClass(@NonNull Class<?> viewClass)
JsonMappercloneWithViewClass in interface JsonMapperviewClass - The view class to use for serialization and deserialization.@NonNull public JsonStreamConfig getStreamConfig()
getStreamConfig in interface JsonMapper@NonNull public Processor<byte[],JsonNode> createReactiveParser(@NonNull Consumer<Processor<byte[],JsonNode>> onSubscribe, boolean streamArray)
JsonMappercreateReactiveParser in interface JsonMapperonSubscribe - An additional function to invoke with this processor when the returned processor is subscribed to.streamArray - Whether to return a top-level json array as a stream of elements rather than a single array.@NonNull public Optional<JsonFeatures> detectFeatures(@NonNull AnnotationMetadata annotations)
JsonMapperJsonFeatures from the given annotation data.detectFeatures in interface JsonMapperannotations - The annotations to scan.JsonMapper.cloneWithFeatures(io.micronaut.json.JsonFeatures), or an empty optional if there were no feature
annotations detected (or feature annotations are not supported).