Class JsonNodeTreeCodec

java.lang.Object
io.micronaut.jackson.core.tree.JsonNodeTreeCodec

public final class JsonNodeTreeCodec extends Object
Codec for transforming JsonNode from and to json streams.
Since:
3.1
Author:
Jonas Konrad
  • Method Details

    • getInstance

      public static JsonNodeTreeCodec getInstance()
      Returns:
      The default instance, using JsonStreamConfig.DEFAULT.
    • withConfig

      public JsonNodeTreeCodec withConfig(JsonStreamConfig config)
      Parameters:
      config - The stream config to use.
      Returns:
      A new codec that will use the given stream config.
    • readTree

      public JsonNode readTree(com.fasterxml.jackson.core.JsonParser p) throws IOException
      Read a json node from a stream.
      Parameters:
      p - The stream to parse.
      Returns:
      The parsed json node.
      Throws:
      IOException - IOException
    • writeTree

      public void writeTree(com.fasterxml.jackson.core.JsonGenerator generator, JsonNode tree) throws IOException
      Write a json node to a json stream.
      Parameters:
      generator - The output json stream.
      tree - The node to write.
      Throws:
      IOException - IOException
    • treeAsTokens

      public com.fasterxml.jackson.core.JsonParser treeAsTokens(JsonNode node)
      Create a new parser that traverses over the given json node.
      Parameters:
      node - The json node to traverse over.
      Returns:
      The parser that will visit the json node.
    • createTreeGenerator

      public TreeGenerator createTreeGenerator()
      Create a JsonGenerator that will return a JsonNode when completed.
      Returns:
      The generator.