Package dev.langchain4j.internal
Class Json
java.lang.Object
dev.langchain4j.internal.Json
JSON helper class. It is supposed to be used by "tools" and "structured output" functionalities.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
The abstract JSON codec interface. -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> T
Convert the given JSON string to an object of the given class.static <T> T
Convert the given JSON string to an object of the given type.static String
Convert 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 class.- Type Parameters:
T
- the type of the object.- Parameters:
json
- the JSON string.type
- the class of the object.- Returns:
- the object.
-
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.
-