List of usage examples for com.fasterxml.jackson.core JsonGenerator close
@Override public abstract void close() throws IOException;
From source file:net.echinopsii.ariane.community.core.directory.wat.json.ds.organisational.EnvironmentJSON.java
public final static void manyEnvironments2JSON(HashSet<Environment> environments, ByteArrayOutputStream outStream) throws IOException { JsonGenerator jgenerator = DirectoryBootstrap.getjFactory().createGenerator(outStream, JsonEncoding.UTF8); jgenerator.writeStartObject();/*from w w w . ja v a 2s. c o m*/ jgenerator.writeArrayFieldStart("environments"); Iterator<Environment> iter = environments.iterator(); while (iter.hasNext()) { Environment current = iter.next(); EnvironmentJSON.environment2JSON(current, jgenerator); } jgenerator.writeEndArray(); jgenerator.writeEndObject(); jgenerator.close(); }
From source file:net.echinopsii.ariane.community.core.directory.wat.json.ds.technical.network.RoutingAreaJSON.java
public final static void manyRoutingAreas2JSON(HashSet<RoutingArea> routingAreas, ByteArrayOutputStream outStream) throws IOException { JsonGenerator jgenerator = DirectoryBootstrap.getjFactory().createGenerator(outStream, JsonEncoding.UTF8); jgenerator.writeStartObject();/*from w w w .j a va 2s . co m*/ jgenerator.writeArrayFieldStart("routingAreas"); Iterator<RoutingArea> iter = routingAreas.iterator(); while (iter.hasNext()) { RoutingArea current = iter.next(); RoutingAreaJSON.routingArea2JSON(current, jgenerator); } jgenerator.writeEndArray(); jgenerator.writeEndObject(); jgenerator.close(); }
From source file:net.echinopsii.ariane.community.core.directory.wat.json.ds.technical.network.DatacenterJSON.java
public final static void manyDatacenters2JSON(HashSet<Datacenter> datacenters, ByteArrayOutputStream outStream) throws IOException { JsonGenerator jgenerator = DirectoryBootstrap.getjFactory().createGenerator(outStream, JsonEncoding.UTF8); jgenerator.writeStartObject();/* ww w . ja v a2 s .c o m*/ jgenerator.writeArrayFieldStart("datacenters"); Iterator<Datacenter> iter = datacenters.iterator(); while (iter.hasNext()) { Datacenter current = iter.next(); DatacenterJSON.datacenter2JSON(current, jgenerator); } jgenerator.writeEndArray(); jgenerator.writeEndObject(); jgenerator.close(); }
From source file:com.netflix.hystrix.serial.SerialHystrixDashboardData.java
public static String toJsonString(HystrixCommandMetrics commandMetrics) { StringWriter jsonString = new StringWriter(); try {//from w ww . j a v a 2 s .c o m JsonGenerator json = jsonFactory.createGenerator(jsonString); writeCommandMetrics(commandMetrics, json); json.close(); return jsonString.getBuffer().toString(); } catch (IOException ioe) { throw new RuntimeException(ioe); } }
From source file:com.meetingninja.csse.database.GroupDatabaseAdapter.java
public static Group updateGroup(Group group) throws IOException { ByteArrayOutputStream json = new ByteArrayOutputStream(); // this type of print stream allows us to get a string easily PrintStream ps = new PrintStream(json); JsonGenerator jgen = JFACTORY.createGenerator(ps, JsonEncoding.UTF8); // Build JSON Object for Title jgen.writeStartObject();//w w w . ja va 2 s .co m jgen.writeStringField(Keys.Group.ID, group.getGroupID()); jgen.writeStringField("field", Keys.Group.TITLE); jgen.writeStringField("value", group.getGroupTitle()); jgen.writeEndObject(); jgen.close(); String payloadTitle = json.toString("UTF8"); ps.close(); json = new ByteArrayOutputStream(); // this type of print stream allows us to get a string easily ps = new PrintStream(json); jgen = JFACTORY.createGenerator(ps, JsonEncoding.UTF8); // Build JSON Object for Group members jgen.writeStartObject(); jgen.writeStringField(Keys.Group.ID, group.getGroupID()); jgen.writeStringField("field", Keys.Group.MEMBERS); jgen.writeArrayFieldStart("value"); for (User member : group.getMembers()) { jgen.writeStartObject(); jgen.writeStringField(Keys.User.ID, member.getID()); jgen.writeEndObject(); } jgen.writeEndArray(); jgen.writeEndObject(); jgen.close(); String payloadMembers = json.toString("UTF8"); ps.close(); // Establish connection sendSingleEdit(payloadTitle); String response = sendSingleEdit(payloadMembers); JsonNode groupNode = MAPPER.readTree(response); return parseGroup(groupNode, new Group()); }
From source file:net.echinopsii.ariane.community.core.directory.wat.json.ds.organisational.ApplicationJSON.java
public final static void manyApplications2JSON(HashSet<Application> applications, ByteArrayOutputStream outStream) throws IOException { JsonGenerator jgenerator = DirectoryBootstrap.getjFactory().createGenerator(outStream, JsonEncoding.UTF8); jgenerator.writeStartObject();/*from w w w . j av a2 s . c o m*/ jgenerator.writeArrayFieldStart("applications"); Iterator<Application> iterC = applications.iterator(); while (iterC.hasNext()) { Application current = iterC.next(); ApplicationJSON.application2JSON(current, jgenerator); } jgenerator.writeEndArray(); jgenerator.writeEndObject(); jgenerator.close(); }
From source file:com.netflix.hystrix.serial.SerialHystrixDashboardData.java
public static String toJsonString(HystrixCollapserMetrics collapserMetrics) { StringWriter jsonString = new StringWriter(); try {/* w ww . jav a 2s . c o m*/ JsonGenerator json = jsonFactory.createGenerator(jsonString); writeCollapserMetrics(collapserMetrics, json); json.close(); return jsonString.getBuffer().toString(); } catch (IOException ioe) { throw new RuntimeException(ioe); } }
From source file:com.netflix.hystrix.serial.SerialHystrixDashboardData.java
public static String toJsonString(HystrixThreadPoolMetrics threadPoolMetrics) { StringWriter jsonString = new StringWriter(); try {// w w w.j a v a 2 s . c o m JsonGenerator json = jsonFactory.createGenerator(jsonString); writeThreadPoolMetrics(threadPoolMetrics, json); json.close(); return jsonString.getBuffer().toString(); } catch (IOException ioe) { throw new RuntimeException(ioe); } }
From source file:net.echinopsii.ariane.community.core.directory.wat.json.ds.technical.system.OSInstanceJSON.java
public final static void manyOSInstances2JSON(HashSet<OSInstance> osInstances, ByteArrayOutputStream outStream) throws IOException { JsonGenerator jgenerator = DirectoryBootstrap.getjFactory().createGenerator(outStream, JsonEncoding.UTF8); jgenerator.writeStartObject();//from w w w. ja v a 2 s. c o m jgenerator.writeArrayFieldStart("osInstances"); Iterator<OSInstance> iter = osInstances.iterator(); while (iter.hasNext()) { OSInstance current = iter.next(); OSInstanceJSON.osInstance2JSON(current, jgenerator); } jgenerator.writeEndArray(); jgenerator.writeEndObject(); jgenerator.close(); }
From source file:org.ng200.openolympus.controller.auth.AuthenticationResponder.java
public static void writeLoginStatusJson(Writer out, String authMessage, List<String> captchaErrorCodes) throws IOException, JsonGenerationException { final JsonFactory factory = new JsonFactory(); final JsonGenerator generator = factory.createGenerator(out); generator.writeStartObject();//from w w w .j ava 2 s . c o m generator.writeStringField("auth", authMessage); if (captchaErrorCodes != null && !captchaErrorCodes.isEmpty()) { generator.writeArrayFieldStart("captchas"); for (final String captchaErrorCode : captchaErrorCodes) { generator.writeString(captchaErrorCode); } generator.writeEndArray(); } else { generator.writeNullField("captchas"); } generator.writeEndObject(); generator.close(); }