List of usage examples for com.fasterxml.jackson.core JsonGenerator writeEndArray
public abstract void writeEndArray() throws IOException, JsonGenerationException;
From source file:org.loklak.objects.AbstractIndexEntry.java
public static void writeArray(JsonGenerator json, String fieldName, Collection<String> array) throws IOException { json.writeArrayFieldStart(fieldName); for (String o : array) json.writeObject(o);/*from w w w. j ava2s . c o m*/ json.writeEndArray(); }
From source file:net.echinopsii.ariane.community.plugin.rabbitmq.directory.json.RabbitmqNodeJSON.java
public final static void manyRabbitmqNodes2JSON(HashSet<RabbitmqNode> nodes, ByteArrayOutputStream outStream) throws IOException { JsonGenerator jgenerator = RabbitmqDirectoryBootstrap.getjFactory().createGenerator(outStream, JsonEncoding.UTF8);/* w ww . j av a2 s . c om*/ jgenerator.writeStartObject(); jgenerator.writeArrayFieldStart("rabbitmqnodes"); for (RabbitmqNode node : nodes) rabbitmqNode2JSON(node, jgenerator); jgenerator.writeEndArray(); jgenerator.writeEndObject(); jgenerator.close(); }
From source file:net.echinopsii.ariane.community.plugin.rabbitmq.directory.json.RabbitmqClusterJSON.java
public final static void manyRabbitmqClusters2JSON(HashSet<RabbitmqCluster> clusters, ByteArrayOutputStream outStream) throws IOException { JsonGenerator jgenerator = RabbitmqDirectoryBootstrap.getjFactory().createGenerator(outStream, JsonEncoding.UTF8);//from w w w .j a va2 s . co m jgenerator.writeStartObject(); jgenerator.writeArrayFieldStart("rabbitmqclusters"); for (RabbitmqCluster cluster : clusters) rabbitmqCluster2JSON(cluster, jgenerator); jgenerator.writeEndArray(); jgenerator.writeEndObject(); jgenerator.close(); }
From source file:com.tellapart.taba.Transport.java
/** * Encode a single Event.//www . ja va 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:com.google.openrtb.json.OpenRtbJsonUtils.java
/** * Writes a long array if not empty, using quotes for values that are too big. * * @see #writeLong(long, JsonGenerator)//from w w w . j av a 2s . c o m */ public static void writeLongs(String fieldName, List<Long> data, JsonGenerator gen) throws IOException { if (!data.isEmpty()) { gen.writeArrayFieldStart(fieldName); for (long d : data) { writeLong(d, gen); } gen.writeEndArray(); } }
From source file:com.google.openrtb.json.OpenRtbJsonUtils.java
/** * Writes a string array if not empty./* w w w . j a v a 2s . c om*/ */ public static void writeStrings(String fieldName, List<String> data, JsonGenerator gen) throws IOException { if (!data.isEmpty()) { gen.writeArrayFieldStart(fieldName); for (String d : data) { gen.writeString(d); } gen.writeEndArray(); } }
From source file:com.google.openrtb.json.OpenRtbJsonUtils.java
/** * Writes an int array if not empty.//from www . jav a 2s. c o m */ public static void writeInts(String fieldName, List<Integer> data, JsonGenerator gen) throws IOException { if (!data.isEmpty()) { gen.writeArrayFieldStart(fieldName); for (Integer d : data) { gen.writeNumber(d); } gen.writeEndArray(); } }
From source file:org.bndtools.rt.repository.marshall.CapReqJson.java
public static void writeRequirementArray(Collection<? extends Requirement> requirements, JsonGenerator generator) throws IOException { generator.writeStartArray();//from ww w .j av a2 s. co m for (Requirement req : requirements) { writeRequirement(req, generator); } generator.writeEndArray(); }
From source file:org.bndtools.rt.repository.marshall.CapReqJson.java
public static void writeCapabilityArray(Collection<? extends Capability> capabilities, JsonGenerator generator) throws IOException { generator.writeStartArray();//from ww w . jav a2 s . c o m for (Capability cap : capabilities) { writeCapability(cap, generator); } generator.writeEndArray(); }
From source file:com.netflix.hystrix.serial.SerialHystrixRequestEvents.java
private static void serializeRequestEvents(HystrixRequestEvents requestEvents, JsonGenerator json) { try {/* w w w . ja va2 s . c o m*/ json.writeStartArray(); for (Map.Entry<HystrixRequestEvents.ExecutionSignature, List<Integer>> entry : requestEvents .getExecutionsMappedToLatencies().entrySet()) { convertExecutionToJson(json, entry.getKey(), entry.getValue()); } json.writeEndArray(); json.close(); } catch (Exception e) { throw new RuntimeException(e); } }