com.marklogic.hub.util.json.JSONStreamWriter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of marklogic-data-hub Show documentation
Show all versions of marklogic-data-hub Show documentation
Library for Creating an Operational Data Hub on MarkLogic
package com.marklogic.hub.util.json;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.charset.StandardCharsets;
public class JSONStreamWriter {
private static final Logger logger = LoggerFactory.getLogger(JSONStreamWriter.class);
final OutputStream out;
public JSONStreamWriter(OutputStream out) {
this.out = out;
}
public void write(Object val) throws IOException {
String stringToSer = JSONObject.writeValueAsString(val);
if (StringUtils.isNotEmpty(stringToSer)) {
out.write(stringToSer.getBytes(StandardCharsets.UTF_8));
out.close();
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy