Class Jackson3JsonCodec

java.lang.Object
dev.langchain4j.jackson3.Jackson3JsonCodec
All Implemented Interfaces:
Json.JsonCodec

public class Jackson3JsonCodec extends Object implements Json.JsonCodec
Jackson 3 implementation of Json.JsonCodec.

Configuration mirrors the Jackson 2 default codec, including the 2.x defaults that Jackson 3 changed. Those are pinned explicitly so that swapping the codec does not also change behaviour.

  • Constructor Details

    • Jackson3JsonCodec

      public Jackson3JsonCodec()
    • Jackson3JsonCodec

      public Jackson3JsonCodec(tools.jackson.databind.ObjectMapper objectMapper)
  • Method Details

    • toJson

      public String toJson(Object o)
      Description copied from interface: Json.JsonCodec
      Convert the given object to JSON.
      Specified by:
      toJson in interface Json.JsonCodec
      Parameters:
      o - the object to convert.
      Returns:
      the JSON string.
    • fromJson

      public <T> T fromJson(String json, Class<T> type)
      Description copied from interface: Json.JsonCodec
      Convert the given JSON string to an object of the given class.
      Specified by:
      fromJson in interface Json.JsonCodec
      Type Parameters:
      T - the type of the object.
      Parameters:
      json - the JSON string.
      type - the class of the object.
      Returns:
      the object.
    • fromJson

      public <T> T fromJson(String json, Type type)
      Description copied from interface: Json.JsonCodec
      Convert the given JSON string to an object of the given type.
      Specified by:
      fromJson in interface Json.JsonCodec
      Type Parameters:
      T - the type of the object.
      Parameters:
      json - the JSON string.
      type - the type of the object.
      Returns:
      the object.