io.quarkiverse.loggingjson.jsonb.JsonbJsonFactory Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of quarkiverse-logging-json Show documentation
Show all versions of quarkiverse-logging-json Show documentation
Logging in json with support for custom fields
package io.quarkiverse.loggingjson.jsonb;
import java.util.HashMap;
import javax.json.Json;
import javax.json.stream.JsonGeneratorFactory;
import org.eclipse.yasson.YassonJsonb;
import org.eclipse.yasson.internal.JsonBindingBuilder;
import io.quarkiverse.loggingjson.JsonFactory;
import io.quarkiverse.loggingjson.JsonGenerator;
import io.quarkiverse.loggingjson.StringBuilderWriter;
public class JsonbJsonFactory implements JsonFactory {
private final JsonGeneratorFactory factory;
private final YassonJsonb jsonb;
public JsonbJsonFactory() {
factory = Json.createGeneratorFactory(new HashMap<>());
jsonb = (YassonJsonb) new JsonBindingBuilder().build();
}
@Override
public JsonGenerator createGenerator(StringBuilderWriter writer) {
return new JsonbJsonGenerator(factory.createGenerator(writer), jsonb);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy