Example usage for com.fasterxml.jackson.core JsonGenerator writeEndObject

List of usage examples for com.fasterxml.jackson.core JsonGenerator writeEndObject

Introduction

In this page you can find the example usage for com.fasterxml.jackson.core JsonGenerator writeEndObject.

Prototype

public abstract void writeEndObject() throws IOException, JsonGenerationException;

Source Link

Document

Method for writing closing marker of a JSON Object value (character '}'; plus possible white space decoration if pretty-printing is enabled).

Usage

From source file:com.google.openrtb.json.OpenRtbJsonWriter.java

public final void writeBanner(Banner banner, JsonGenerator gen) throws IOException {
    gen.writeStartObject();/*from   w w w . java 2 s  . com*/
    writeBannerFields(banner, gen);
    writeExtensions(banner, gen);
    gen.writeEndObject();
}

From source file:com.google.openrtb.json.OpenRtbJsonWriter.java

public final void writeFormat(Format format, JsonGenerator gen) throws IOException {
    gen.writeStartObject();/*from   ww w  . j  a  v  a 2s .c  o m*/
    writeFormatFields(format, gen);
    writeExtensions(format, gen);
    gen.writeEndObject();
}

From source file:com.google.openrtb.json.OpenRtbJsonWriter.java

public final void writeDevice(Device device, JsonGenerator gen) throws IOException {
    gen.writeStartObject();//w w  w .  ja  va 2 s .c  o  m
    writeDeviceFields(device, gen);
    writeExtensions(device, gen);
    gen.writeEndObject();
}

From source file:com.google.openrtb.json.OpenRtbJsonWriter.java

public final void writeContent(Content content, JsonGenerator gen) throws IOException {
    gen.writeStartObject();/*from   w  w w  .j av  a  2s .c o  m*/
    writeContentFields(content, gen);
    writeExtensions(content, gen);
    gen.writeEndObject();
}

From source file:com.google.openrtb.json.OpenRtbJsonWriter.java

public final void writeSegment(Segment segment, JsonGenerator gen) throws IOException {
    gen.writeStartObject();//from   w ww .  j a  v  a2 s.  c  o  m
    writeSegmentFields(segment, gen);
    writeExtensions(segment, gen);
    gen.writeEndObject();
}

From source file:com.google.openrtb.json.OpenRtbJsonWriter.java

/**
 * Serializes a {@link BidResponse} to JSON, with a provided {@link JsonGenerator}
 * which allows several choices of output and encoding.
 *///  w w  w . j a  v  a 2 s .  co m
public final void writeBidResponse(BidResponse resp, JsonGenerator gen) throws IOException {
    gen.writeStartObject();
    writeBidResponseFields(resp, gen);
    writeExtensions(resp, gen);
    gen.writeEndObject();
    gen.flush();
}

From source file:com.google.openrtb.json.OpenRtbJsonWriter.java

public final void writeSeatBid(SeatBid seatbid, JsonGenerator gen) throws IOException {
    gen.writeStartObject();/*from  w w w. ja va2 s  . co  m*/
    writeSeatBidFields(seatbid, gen);
    writeExtensions(seatbid, gen);
    gen.writeEndObject();
}

From source file:com.greplin.gec.GecLog4jAppender.java

/**
 * Writes a formatted exception to the given writer.
 *
 * @param message   the log message/*  w  w w.ja  va 2s .c o m*/
 * @param throwable the exception
 * @param level     the error level
 * @param out       the destination
 * @throws IOException if there are IO errors in the destination
 */
void writeFormattedException(final String message, final Throwable throwable, final Level level,
        final Writer out) throws IOException {
    JsonGenerator generator = new JsonFactory().createJsonGenerator(out);

    Throwable rootThrowable = throwable;
    while (this.passthroughExceptions.contains(rootThrowable.getClass()) && rootThrowable.getCause() != null) {
        rootThrowable = rootThrowable.getCause();
    }

    generator.writeStartObject();
    generator.writeStringField("project", this.project);
    generator.writeStringField("environment", this.environment);
    generator.writeStringField("serverName", this.serverName);
    generator.writeStringField("backtrace", ExceptionUtils.getStackTrace(throwable));
    generator.writeStringField("message", rootThrowable.getMessage());
    generator.writeStringField("logMessage", message);
    generator.writeStringField("type", rootThrowable.getClass().getName());
    if (level != Level.ERROR) {
        generator.writeStringField("errorLevel", level.toString());
    }
    writeContext(generator);
    generator.writeEndObject();
    generator.close();
}

From source file:com.google.openrtb.json.OpenRtbJsonWriter.java

public final void writeProducer(Producer producer, JsonGenerator gen) throws IOException {
    gen.writeStartObject();//from   www. j a v  a 2  s. c  o m
    writeProducerFields(producer, gen);
    writeExtensions(producer, gen);
    gen.writeEndObject();
}

From source file:com.basho.riak.client.raw.http.ConversionUtil.java

/**
 * Converts a {@link BucketProperties} to a JSON string
 * @param bp/*from  www.j  a  v a 2s  .  co  m*/
 * @return a String of JSON that is acceptable to {@link RiakBucketInfo}
 * @throws IOException
 * TODO: move this to a custom serializer?
 */
private static String toJSON(BucketProperties bp) throws IOException {
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    JsonGenerator jg = new JsonFactory().createJsonGenerator(out, JsonEncoding.UTF8);

    jg.writeStartObject();
    writeIfNotNull(jg, bp.getAllowSiblings(), Constants.FL_SCHEMA_ALLOW_MULT);
    writeIfNotNull(jg, bp.getNVal(), Constants.FL_SCHEMA_NVAL);
    writeIfNotNull(jg, bp.getLastWriteWins(), Constants.FL_SCHEMA_LAST_WRITE_WINS);
    writeIfNotNull(jg, bp.getBackend(), Constants.FL_SCHEMA_BACKEND);
    writeIfNotNull(jg, bp.getSmallVClock(), Constants.FL_SCHEMA_SMALL_VCLOCK);
    writeIfNotNull(jg, bp.getBigVClock(), Constants.FL_SCHEMA_BIG_VCLOCK);
    writeIfNotNull(jg, bp.getYoungVClock(), Constants.FL_SCHEMA_YOUNG_VCLOCK);
    writeIfNotNull(jg, bp.getOldVClock(), Constants.FL_SCHEMA_OLD_VCLOCK);
    writeIfNotNull(jg, bp.getR(), Constants.FL_SCHEMA_R);
    writeIfNotNull(jg, bp.getRW(), Constants.FL_SCHEMA_RW);
    writeIfNotNull(jg, bp.getW(), Constants.FL_SCHEMA_W);
    writeIfNotNull(jg, bp.getDW(), Constants.FL_SCHEMA_DW);
    writeIfNotNull(jg, bp.getPR(), Constants.FL_SCHEMA_PR);
    writeIfNotNull(jg, bp.getPW(), Constants.FL_SCHEMA_PW);
    writeIfNotNull(jg, bp.getBasicQuorum(), Constants.FL_SCHEMA_BASIC_QUORUM);
    writeIfNotNull(jg, bp.getNotFoundOK(), Constants.FL_SCHEMA_NOT_FOUND_OK);
    writeIfNotNull(jg, bp.getChashKeyFunction(), Constants.FL_SCHEMA_CHASHFUN);
    writeIfNotNull(jg, bp.getLinkWalkFunction(), Constants.FL_SCHEMA_LINKFUN);
    writeIfNotNull(jg, bp.getPostcommitHooks(), Constants.FL_SCHEMA_POSTCOMMIT);
    writeIfNotNull(jg, bp.getPrecommitHooks(), Constants.FL_SCHEMA_PRECOMMIT);
    writeIfNotNull(jg, bp.getSearch(), Constants.FL_SCHEMA_SEARCH);

    jg.writeEndObject();

    jg.flush();
    return CharsetUtils.asUTF8String(out.toByteArray());
}