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

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

Introduction

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

Prototype

@Override
public abstract void close() throws IOException;

Source Link

Document

Method called to close this generator, so that no more content can be written.

Usage

From source file:net.echinopsii.ariane.community.core.directory.wat.json.ds.technical.network.SubnetJSON.java

public final static void oneSubnet2JSON(Subnet subnet, ByteArrayOutputStream outStream) throws IOException {
    JsonGenerator jgenerator = DirectoryBootstrap.getjFactory().createGenerator(outStream, JsonEncoding.UTF8);
    SubnetJSON.subnet2JSON(subnet, jgenerator);
    jgenerator.close();
}

From source file:net.echinopsii.ariane.community.plugin.rabbitmq.directory.json.RabbitmqClusterJSON.java

public final static void oneRabbitmqCluster2JSON(RabbitmqCluster cluster, ByteArrayOutputStream outStream)
        throws IOException {
    JsonGenerator jgenerator = RabbitmqDirectoryBootstrap.getjFactory().createGenerator(outStream,
            JsonEncoding.UTF8);/*from  w  w  w .j  av  a 2s .  c o m*/
    rabbitmqCluster2JSON(cluster, jgenerator);
    jgenerator.close();
}

From source file:com.tellapart.taba.Transport.java

/**
 * Encode a single Event.//from   www  .  j  a v  a  2  s . co  m
 *
 * @param event   Event to encode.
 * @param factory
 *
 * @return  Encoded event String.
 */
protected static String encodeEvent(Event event, JsonFactory factory) throws IOException {
    ByteArrayOutputStream encodedPayload = new ByteArrayOutputStream();
    JsonGenerator payloadGenerator = factory.createGenerator(encodedPayload);
    event.getPayload().serialize(payloadGenerator);
    payloadGenerator.close();

    ByteArrayOutputStream encodedEvent = new ByteArrayOutputStream();
    JsonGenerator eventGenerator = factory.createGenerator(encodedEvent);
    eventGenerator.writeStartArray();
    eventGenerator.writeString(event.getTabType());
    eventGenerator.writeNumber(event.getTimestamp());
    eventGenerator.writeString(encodedPayload.toString());
    eventGenerator.writeEndArray();
    eventGenerator.close();

    return encodedEvent.toString();
}

From source file:net.echinopsii.ariane.community.plugin.rabbitmq.directory.json.RabbitmqNodeJSON.java

public final static void oneRabbitmqNode2JSON(RabbitmqNode node, ByteArrayOutputStream outStream)
        throws IOException {
    JsonGenerator jgenerator = RabbitmqDirectoryBootstrap.getjFactory().createGenerator(outStream,
            JsonEncoding.UTF8);//from   w ww  .j  a  v  a2s.  c  o m
    rabbitmqNode2JSON(node, jgenerator);
    jgenerator.close();
}

From source file:net.echinopsii.ariane.community.core.directory.wat.json.ds.organisational.ApplicationJSON.java

public final static void oneApplication2JSON(Application application, ByteArrayOutputStream outStream)
        throws IOException {
    JsonGenerator jgenerator = DirectoryBootstrap.getjFactory().createGenerator(outStream, JsonEncoding.UTF8);
    ApplicationJSON.application2JSON(application, jgenerator);
    jgenerator.close();
}

From source file:net.echinopsii.ariane.community.core.directory.wat.json.ds.technical.network.RoutingAreaJSON.java

public final static void oneRoutingArea2JSON(RoutingArea routingArea, ByteArrayOutputStream outStream)
        throws IOException {
    JsonGenerator jgenerator = DirectoryBootstrap.getjFactory().createGenerator(outStream, JsonEncoding.UTF8);
    RoutingAreaJSON.routingArea2JSON(routingArea, jgenerator);
    jgenerator.close();
}

From source file:net.echinopsii.ariane.community.core.directory.wat.json.ds.technical.network.DatacenterJSON.java

public final static void oneDatacenter2JSON(Datacenter datacenter, ByteArrayOutputStream outStream)
        throws IOException {
    JsonGenerator jgenerator = DirectoryBootstrap.getjFactory().createGenerator(outStream, JsonEncoding.UTF8);
    DatacenterJSON.datacenter2JSON(datacenter, jgenerator);
    jgenerator.close();
}

From source file:net.echinopsii.ariane.community.core.directory.wat.json.ds.technical.system.OSInstanceJSON.java

public final static void oneOSInstance2JSON(OSInstance osInstance, ByteArrayOutputStream outStream)
        throws IOException {
    JsonGenerator jgenerator = DirectoryBootstrap.getjFactory().createGenerator(outStream, JsonEncoding.UTF8);
    OSInstanceJSON.osInstance2JSON(osInstance, jgenerator);
    jgenerator.close();
}

From source file:com.cedarsoft.couchdb.io.ActionResponseSerializerTest.java

License:asdf

/**
 * Only used for tests/*from  w w w .  j  a v  a 2 s  . c  o  m*/
 * @param object
 * @param out
 * @throws IOException
 */
@Deprecated
public static void serialize(@Nonnull ActionResponse object, @Nonnull OutputStream out) throws IOException {
    JsonFactory jsonFactory = JacksonSupport.getJsonFactory();

    JsonGenerator generator = jsonFactory.createJsonGenerator(out, JsonEncoding.UTF8);

    generator.writeStartObject();

    serialize(generator, object);
    generator.writeEndObject();

    generator.close();
}

From source file:com.netflix.hystrix.contrib.requests.stream.HystrixRequestEventsJsonStream.java

public static String convertRequestsToJson(Collection<HystrixRequestEvents> requests) throws IOException {
    StringWriter jsonString = new StringWriter();
    JsonGenerator json = jsonFactory.createGenerator(jsonString);

    json.writeStartArray();/*from   w w  w  . j av  a  2s  .  c o m*/
    for (HystrixRequestEvents request : requests) {
        writeRequestAsJson(json, request);
    }
    json.writeEndArray();
    json.close();
    return jsonString.getBuffer().toString();
}