Package dev.langchain4j.internal
Class Json
java.lang.Object
dev.langchain4j.internal.Json
A utility class for JSON.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceThe abstract JSON codec interface. -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> TConvert the given JSON string to an object of the given type.static InputStreamtoInputStream(Object o, Class<?> type) Convert the given object to anInputStream.static StringConvert the given object to JSON.
-
Method Details
-
toJson
Convert the given object to JSON.- Parameters:
o- the object to convert.- Returns:
- the JSON string.
-
fromJson
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
Convert the given object to anInputStream.- Parameters:
o- the object to convert.type- the type of the object.- Returns:
- the
InputStream. - Throws:
IOException- if an I/O error occurs.
-