Fix [Client] [Exporting Messages] JSON Format #6
@ -19,12 +19,11 @@ type JSONExporter struct {
|
|||||||
Encoder JSONEncoderFunc
|
Encoder JSONEncoderFunc
|
||||||
}
|
}
|
||||||
|
|
||||||
// Export writes messages to the writer using the custom JSON encoder
|
// Export writes messages to the writer as a JSON array using the custom JSON encoder
|
||||||
func (e *JSONExporter) Export(messages []map[string]any, writer io.Writer) error {
|
func (e *JSONExporter) Export(messages []map[string]any, writer io.Writer) error {
|
||||||
for _, msg := range messages {
|
// Use the encoder to write the entire slice as a JSON array
|
||||||
if err := e.Encoder(msg, writer); err != nil {
|
if err := e.Encoder(messages, writer); err != nil {
|
||||||
return fmt.Errorf("failed to encode message to JSON: %v", err)
|
return fmt.Errorf("failed to encode messages to JSON: %v", err)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user