Class JacksonOpenApiJsonMapper

java.lang.Object
io.micronaut.openapi.jackson.JacksonOpenApiJsonMapper
All Implemented Interfaces:
io.micronaut.json.JsonMapper

public final class JacksonOpenApiJsonMapper extends Object implements io.micronaut.json.JsonMapper
A JsonMapper backed by a Jackson ObjectMapper.

Trees are exchanged as Micronaut JsonNode instances, converted through plain Java maps, lists and scalars. Jackson exceptions are rethrown as IOException, matching the JsonMapper contract.

Since:
8.0.0
  • Constructor Details

    • JacksonOpenApiJsonMapper

      public JacksonOpenApiJsonMapper(tools.jackson.databind.ObjectMapper objectMapper)
      Parameters:
      objectMapper - The Jackson mapper to delegate to
  • Method Details

    • getObjectMapper

      public tools.jackson.databind.ObjectMapper getObjectMapper()
      Returns:
      The underlying Jackson mapper
    • readValueFromTree

      @Nullable public <T> T readValueFromTree(io.micronaut.json.tree.JsonNode tree, io.micronaut.core.type.Argument<T> type) throws IOException
      Specified by:
      readValueFromTree in interface io.micronaut.json.JsonMapper
      Throws:
      IOException
    • readValue

      @Nullable public <T> T readValue(InputStream inputStream, io.micronaut.core.type.Argument<T> type) throws IOException
      Specified by:
      readValue in interface io.micronaut.json.JsonMapper
      Throws:
      IOException
    • readValue

      @Nullable public <T> T readValue(byte[] byteArray, io.micronaut.core.type.Argument<T> type) throws IOException
      Specified by:
      readValue in interface io.micronaut.json.JsonMapper
      Throws:
      IOException
    • readValue

      @Nullable public <T> T readValue(String string, io.micronaut.core.type.Argument<T> type) throws IOException
      Specified by:
      readValue in interface io.micronaut.json.JsonMapper
      Throws:
      IOException
    • writeValueToTree

      public io.micronaut.json.tree.JsonNode writeValueToTree(@Nullable @Nullable Object value) throws IOException
      Specified by:
      writeValueToTree in interface io.micronaut.json.JsonMapper
      Throws:
      IOException
    • writeValueToTree

      public <T> io.micronaut.json.tree.JsonNode writeValueToTree(io.micronaut.core.type.Argument<T> type, @Nullable T value) throws IOException
      Specified by:
      writeValueToTree in interface io.micronaut.json.JsonMapper
      Throws:
      IOException
    • writeValue

      public void writeValue(OutputStream outputStream, @Nullable @Nullable Object object) throws IOException
      Specified by:
      writeValue in interface io.micronaut.json.JsonMapper
      Throws:
      IOException
    • writeValue

      public <T> void writeValue(OutputStream outputStream, io.micronaut.core.type.Argument<T> type, @Nullable T object) throws IOException
      Specified by:
      writeValue in interface io.micronaut.json.JsonMapper
      Throws:
      IOException
    • writeValueAsBytes

      public byte[] writeValueAsBytes(@Nullable @Nullable Object object) throws IOException
      Specified by:
      writeValueAsBytes in interface io.micronaut.json.JsonMapper
      Throws:
      IOException
    • writeValueAsBytes

      public <T> byte[] writeValueAsBytes(io.micronaut.core.type.Argument<T> type, @Nullable T object) throws IOException
      Specified by:
      writeValueAsBytes in interface io.micronaut.json.JsonMapper
      Throws:
      IOException
    • writeValueAsString

      public String writeValueAsString(@Nullable @Nullable Object object) throws IOException
      Specified by:
      writeValueAsString in interface io.micronaut.json.JsonMapper
      Throws:
      IOException
    • updateValueFromTree

      public void updateValueFromTree(Object value, io.micronaut.json.tree.JsonNode tree) throws IOException
      Specified by:
      updateValueFromTree in interface io.micronaut.json.JsonMapper
      Throws:
      IOException
    • updateValue

      public <T> T updateValue(T value, io.micronaut.json.tree.JsonNode tree) throws IOException
      Updates a value from a tree with ObjectMapper.readerForUpdating(Object).
      Type Parameters:
      T - The value type
      Parameters:
      value - The value to update
      tree - The tree
      Returns:
      The result, which is a new instance if the type's deserializer cannot merge into an existing one
      Throws:
      IOException - if the tree cannot be read
    • getStreamConfig

      public io.micronaut.json.JsonStreamConfig getStreamConfig()
      Specified by:
      getStreamConfig in interface io.micronaut.json.JsonMapper