Package dev.langchain4j.data.message
Interface ChatMessageJsonCodec
- All Known Implementing Classes:
GsonChatMessageJsonCodec
public interface ChatMessageJsonCodec
A codec for serializing and deserializing
ChatMessage
objects to and from JSON.-
Method Summary
Modifier and TypeMethodDescriptionmessageFromJson
(String json) Deserializes a JSON string to aChatMessage
object.messagesFromJson
(String json) Deserializes a JSON string to a list ofChatMessage
objects.messagesToJson
(List<ChatMessage> messages) Serializes a list ofChatMessage
objects to a JSON string.messageToJson
(ChatMessage message) Serializes aChatMessage
object to a JSON string.
-
Method Details
-
messageFromJson
Deserializes a JSON string to aChatMessage
object.- Parameters:
json
- the JSON string.- Returns:
- the deserialized
ChatMessage
object.
-
messagesFromJson
Deserializes a JSON string to a list ofChatMessage
objects.- Parameters:
json
- the JSON string.- Returns:
- the deserialized list of
ChatMessage
objects.
-
messageToJson
Serializes aChatMessage
object to a JSON string.- Parameters:
message
- theChatMessage
object.- Returns:
- the serialized JSON string.
-
messagesToJson
Serializes a list ofChatMessage
objects to a JSON string.- Parameters:
messages
- the list ofChatMessage
objects.- Returns:
- the serialized JSON string.
-