Package dev.langchain4j.data.message
Class GsonChatMessageJsonCodec
java.lang.Object
dev.langchain4j.data.message.GsonChatMessageJsonCodec
- All Implemented Interfaces:
ChatMessageJsonCodec
A codec for serializing and deserializing
ChatMessage objects to and from JSON.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionmessageFromJson(String json) Deserializes a JSON string to aChatMessageobject.messagesFromJson(String json) Deserializes a JSON string to a list ofChatMessageobjects.messagesToJson(List<ChatMessage> messages) Serializes a list ofChatMessageobjects to a JSON string.messageToJson(ChatMessage message) Serializes aChatMessageobject to a JSON string.
-
Constructor Details
-
GsonChatMessageJsonCodec
public GsonChatMessageJsonCodec()Constructs a newGsonChatMessageJsonCodec.
-
-
Method Details
-
messageFromJson
Description copied from interface:ChatMessageJsonCodecDeserializes a JSON string to aChatMessageobject.- Specified by:
messageFromJsonin interfaceChatMessageJsonCodec- Parameters:
json- the JSON string.- Returns:
- the deserialized
ChatMessageobject.
-
messagesFromJson
Description copied from interface:ChatMessageJsonCodecDeserializes a JSON string to a list ofChatMessageobjects.- Specified by:
messagesFromJsonin interfaceChatMessageJsonCodec- Parameters:
json- the JSON string.- Returns:
- the deserialized list of
ChatMessageobjects.
-
messageToJson
Description copied from interface:ChatMessageJsonCodecSerializes aChatMessageobject to a JSON string.- Specified by:
messageToJsonin interfaceChatMessageJsonCodec- Parameters:
message- theChatMessageobject.- Returns:
- the serialized JSON string.
-
messagesToJson
Description copied from interface:ChatMessageJsonCodecSerializes a list ofChatMessageobjects to a JSON string.- Specified by:
messagesToJsonin interfaceChatMessageJsonCodec- Parameters:
messages- the list ofChatMessageobjects.- Returns:
- the serialized JSON string.
-