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

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

Introduction

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

Prototype

public abstract void writeStartObject() throws IOException, JsonGenerationException;

Source Link

Document

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

Usage

From source file:com.predic8.membrane.core.interceptor.administration.AdminRESTInterceptor.java

@Mapping("/admin/rest/clients(/?\\?.*)?")
public Response getClients(QueryParameter params, String relativeRootPath) throws Exception {
    final List<? extends ClientStatistics> clients = getRouter().getExchangeStore().getClientStatistics();

    Collections.sort(clients, ComparatorFactory.getClientStatisticsComparator(params.getString("sort", "name"),
            params.getString("order", "asc")));

    int offset = params.getInt("offset", 0);
    int max = params.getInt("max", clients.size());

    final int total = clients.size();
    final List<? extends ClientStatistics> paginated = clients.subList(offset,
            Math.min(offset + max, clients.size()));

    return json(new JSONContent() {
        public void write(JsonGenerator gen) throws Exception {
            gen.writeStartObject();
            gen.writeArrayFieldStart("clients");
            for (ClientStatistics s : paginated) {
                gen.writeStartObject();/*w ww .ja v a  2 s.c  om*/
                gen.writeStringField("name", s.getClient());
                gen.writeNumberField("count", s.getCount());
                gen.writeNumberField("min", s.getMinDuration());
                gen.writeNumberField("max", s.getMaxDuration());
                gen.writeNumberField("avg", s.getAvgDuration());
                gen.writeEndObject();
            }
            gen.writeEndArray();
            gen.writeNumberField("total", total);
            gen.writeEndObject();
        }
    });
}

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

public final void writeReqAsset(NativeRequest.Asset asset, JsonGenerator gen) throws IOException {
    gen.writeStartObject();
    writeReqAssetFields(asset, gen);//from w  w w.ja  v a2s  .c  o  m
    writeExtensions(asset, gen);
    gen.writeEndObject();
}

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

public final void writeReqTitle(NativeRequest.Asset.Title title, JsonGenerator gen) throws IOException {
    gen.writeStartObject();
    writeReqTitleFields(title, gen);/*from w  ww .  j av a2 s  .c o m*/
    writeExtensions(title, gen);
    gen.writeEndObject();
}

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

public final void writeReqImage(NativeRequest.Asset.Image image, JsonGenerator gen) throws IOException {
    gen.writeStartObject();
    writeReqImageFields(image, gen);/*from   w w w  .  j a  v a 2  s.  c om*/
    writeExtensions(image, gen);
    gen.writeEndObject();
}

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

public final void writeReqData(NativeRequest.Asset.Data data, JsonGenerator gen) throws IOException {
    gen.writeStartObject();
    writeReqDataFields(data, gen);/*  w  w  w  . j a v  a 2  s . co  m*/
    writeExtensions(data, gen);
    gen.writeEndObject();
}

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

public final void writeRespAsset(NativeResponse.Asset asset, JsonGenerator gen) throws IOException {
    gen.writeStartObject();
    writeRespAssetFields(asset, gen);/*from   w ww.  j  a v  a2s . c  o m*/
    writeExtensions(asset, gen);
    gen.writeEndObject();
}

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

public final void writeRespTitle(NativeResponse.Asset.Title title, JsonGenerator gen) throws IOException {
    gen.writeStartObject();
    writeRespTitleFields(title, gen);/*from  ww  w .j ava2 s . c  om*/
    writeExtensions(title, gen);
    gen.writeEndObject();
}

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

public final void writeRespImage(NativeResponse.Asset.Image image, JsonGenerator gen) throws IOException {
    gen.writeStartObject();
    writeRespImageFields(image, gen);/*from  w ww  .j  a  va 2  s. com*/
    writeExtensions(image, gen);
    gen.writeEndObject();
}

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

public final void writeRespVideo(NativeResponse.Asset.Video video, JsonGenerator gen) throws IOException {
    gen.writeStartObject();
    writeRespVideoFields(video, gen);//www. ja  v a2 s .c o m
    writeExtensions(video, gen);
    gen.writeEndObject();
}

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

public final void writeRespData(NativeResponse.Asset.Data data, JsonGenerator gen) throws IOException {
    gen.writeStartObject();
    writeRespDataFields(data, gen);// ww w  . ja  v  a 2 s  .com
    writeExtensions(data, gen);
    gen.writeEndObject();
}