Class Json

java.lang.Object
dev.langchain4j.internal.Json

@Deprecated public class Json extends Object
Deprecated.
Do not use Json from third-party modules. If you need to serialize/deserialize JSON in third-party modules, use Jackson's ObjectMapper. Json can be used only by langchain4j-core and langchain4j modules.
A utility class for JSON.
  • Method Details

    • toJson

      @Deprecated public static String toJson(Object o)
      Deprecated.
      use Jackson's ObjectMapper
      Convert the given object to JSON.
      Parameters:
      o - the object to convert.
      Returns:
      the JSON string.
    • fromJson

      @Deprecated public static <T> T fromJson(String json, Class<T> type)
      Deprecated.
      use Jackson's ObjectMapper
      Convert the given JSON string to an object of the given class.
      Type Parameters:
      T - the type of the object.
      Parameters:
      json - the JSON string.
      type - the class of the object.
      Returns:
      the object.
    • fromJson

      @Deprecated public static <T> T fromJson(String json, Type type)
      Deprecated.
      use Jackson's ObjectMapper
      Convert the given JSON string to an object of the given type.
      Type Parameters:
      T - the type of the object.
      Parameters:
      json - the JSON string.
      type - the type of the object.
      Returns:
      the object.
    • toInputStream

      @Deprecated public static InputStream toInputStream(Object o, Class<?> type) throws IOException
      Deprecated.
      use Jackson's ObjectMapper
      Convert the given object to an InputStream.
      Parameters:
      o - the object to convert.
      type - the type of the object.
      Returns:
      the InputStream.
      Throws:
      IOException - if an I/O error occurs.