
io.honeycomb.libhoney.transport.json.BatchRequestSerializer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of libhoney-java Show documentation
Show all versions of libhoney-java Show documentation
The Java client for sending events honeycomb
The newest version!
package io.honeycomb.libhoney.transport.json;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectWriter;
import io.honeycomb.libhoney.transport.batch.impl.HoneycombBatchConsumer.BatchRequestElement;
import io.honeycomb.libhoney.utils.JsonUtils;
import java.io.IOException;
import java.util.List;
/**
* A serializer that uses Jackson to serializes a list of {@link BatchRequestElement} into
* a valid json request body for the Honeycomb API.
*/
public class BatchRequestSerializer implements JsonSerializer> {
private static final ObjectWriter OBJECT_WRITER;
static {
OBJECT_WRITER = JsonUtils.OBJECT_MAPPER.writerFor(new TypeReference>() {});
}
@Override
public byte[] serialize(final List data) throws IOException {
return OBJECT_WRITER.writeValueAsBytes(data);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy