本文整理匯總了Java中org.codehaus.jackson.JsonGenerator.writeArrayFieldStart方法的典型用法代碼示例。如果您正苦於以下問題:Java JsonGenerator.writeArrayFieldStart方法的具體用法?Java JsonGenerator.writeArrayFieldStart怎麽用?Java JsonGenerator.writeArrayFieldStart使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.codehaus.jackson.JsonGenerator
的用法示例。
在下文中一共展示了JsonGenerator.writeArrayFieldStart方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: serialize
import org.codehaus.jackson.JsonGenerator; //導入方法依賴的package包/類
/**
* Performs the serialization of a OneComponentTime object
*/
@Override
public void serialize(CumulativeTimeBucket ctb,
JsonGenerator jGen,
SerializerProvider serializer)
throws IOException, JsonProcessingException {
jGen.writeStartObject();
Timestamp ts = new Timestamp(ctb.getStartTimeNs()/1000000);
jGen.writeStringField("start-time", ts.toString());
jGen.writeStringField("current-time",
new Timestamp(System.currentTimeMillis()).toString());
jGen.writeNumberField("total-packets", ctb.getTotalPktCnt());
jGen.writeNumberField("average", ctb.getAverageProcTimeNs());
jGen.writeNumberField("min", ctb.getMinTotalProcTimeNs());
jGen.writeNumberField("max", ctb.getMaxTotalProcTimeNs());
jGen.writeNumberField("std-dev", ctb.getTotalSigmaProcTimeNs());
jGen.writeArrayFieldStart("modules");
for (OneComponentTime oct : ctb.getModules()) {
serializer.defaultSerializeValue(oct, jGen);
}
jGen.writeEndArray();
jGen.writeEndObject();
}
開發者ID:vishalshubham,項目名稱:Multipath-Hedera-system-in-Floodlight-controller,代碼行數:26,代碼來源:CumulativeTimeBucketJSONSerializer.java
示例2: serialize
import org.codehaus.jackson.JsonGenerator; //導入方法依賴的package包/類
@Override
public void serialize(VirtualNetwork vNet, JsonGenerator jGen,
SerializerProvider serializer) throws IOException,
JsonProcessingException {
jGen.writeStartObject();
jGen.writeStringField("name", vNet.name);
jGen.writeStringField("guid", vNet.guid);
jGen.writeStringField("gateway", vNet.gateway);
jGen.writeArrayFieldStart("mac");
Iterator<MACAddress> hit = vNet.hosts.iterator();
while (hit.hasNext())
jGen.writeString(hit.next().toString());
jGen.writeEndArray();
jGen.writeEndObject();
}
開發者ID:vishalshubham,項目名稱:Multipath-Hedera-system-in-Floodlight-controller,代碼行數:19,代碼來源:VirtualNetworkSerializer.java
示例3: toJson
import org.codehaus.jackson.JsonGenerator; //導入方法依賴的package包/類
/**
* Build a JSON entry from the parameters. This is public for testing.
*
* @param writer destination
* @param loggerName logger name
* @param timeStamp time_t value
* @param level level string
* @param threadName name of the thread
* @param message rendered message
* @param ti nullable thrown information
* @return the writer
* @throws IOException on any problem
*/
public Writer toJson(final Writer writer,
final String loggerName,
final long timeStamp,
final String level,
final String threadName,
final String message,
final ThrowableInformation ti) throws IOException {
JsonGenerator json = factory.createJsonGenerator(writer);
json.writeStartObject();
json.writeStringField(NAME, loggerName);
json.writeNumberField(TIME, timeStamp);
Date date = new Date(timeStamp);
json.writeStringField(DATE, dateFormat.format(date));
json.writeStringField(LEVEL, level);
json.writeStringField(THREAD, threadName);
json.writeStringField(MESSAGE, message);
if (ti != null) {
//there is some throwable info, but if the log event has been sent over the wire,
//there may not be a throwable inside it, just a summary.
Throwable thrown = ti.getThrowable();
String eclass = (thrown != null) ?
thrown.getClass().getName()
: "";
json.writeStringField(EXCEPTION_CLASS, eclass);
String[] stackTrace = ti.getThrowableStrRep();
json.writeArrayFieldStart(STACK);
for (String row : stackTrace) {
json.writeString(row);
}
json.writeEndArray();
}
json.writeEndObject();
json.flush();
json.close();
return writer;
}
示例4: writeValues
import org.codehaus.jackson.JsonGenerator; //導入方法依賴的package包/類
private void writeValues(final CollectionPage<Object> value, final JsonGenerator jgen) throws IOException {
jgen.writeArrayFieldStart("values");
for (final Object obj : value) {
jgen.writeObject(obj);
}
jgen.writeEndArray();
}
示例5: serialize
import org.codehaus.jackson.JsonGenerator; //導入方法依賴的package包/類
@Override
public void serialize(Device device, JsonGenerator jGen,
SerializerProvider serializer) throws IOException,
JsonProcessingException {
jGen.writeStartObject();
jGen.writeStringField("entityClass", device.getEntityClass().getName());
jGen.writeArrayFieldStart("mac");
jGen.writeString(HexString.toHexString(device.getMACAddress(), 6));
jGen.writeEndArray();
jGen.writeArrayFieldStart("ipv4");
for (Integer ip : device.getIPv4Addresses())
jGen.writeString(IPv4.fromIPv4Address(ip));
jGen.writeEndArray();
jGen.writeArrayFieldStart("vlan");
for (Short vlan : device.getVlanId())
if (vlan >= 0)
jGen.writeNumber(vlan);
jGen.writeEndArray();
jGen.writeArrayFieldStart("attachmentPoint");
for (SwitchPort ap : device.getAttachmentPoints(true)) {
serializer.defaultSerializeValue(ap, jGen);
}
jGen.writeEndArray();
jGen.writeNumberField("lastSeen", device.getLastSeen().getTime());
jGen.writeEndObject();
}
開發者ID:vishalshubham,項目名稱:Multipath-Hedera-system-in-Floodlight-controller,代碼行數:33,代碼來源:DeviceSerializer.java
示例6: createAggregatedResponse
import org.codehaus.jackson.JsonGenerator; //導入方法依賴的package包/類
public static Response createAggregatedResponse(final BasicStatusHolder status, final String performedOn) {
StreamingOutput streamingOutput = new StreamingOutput() {
@Override
public void write(OutputStream outputStream) throws IOException, WebApplicationException {
JsonGenerator jsonGenerator = JacksonFactory.createJsonGenerator(outputStream);
jsonGenerator.writeStartObject();
if (status.hasErrors()) {
jsonGenerator.writeArrayFieldStart("errors");
for (StatusEntry error : status.getErrors()) {
jsonGenerator.writeStartObject();
jsonGenerator.writeNumberField("status", error.getStatusCode());
jsonGenerator.writeStringField("message", error.getMessage());
jsonGenerator.writeEndObject();
}
jsonGenerator.writeEndArray();
} else {
String msg = "Pushing " + performedOn + " to Bintray finished" + (status.hasWarnings() ?
" with warnings, view the log for details" : " to Bintray finished successfully.");
jsonGenerator.writeStringField("message", msg);
}
jsonGenerator.writeEndObject();
jsonGenerator.close();
}
};
int statusCode = HttpStatus.SC_OK;
if (status.hasErrors()) {
statusCode = status.getErrors().size() > 1 ? HttpStatus.SC_CONFLICT : status.getStatusCode();
}
return Response.status(statusCode).entity(streamingOutput).type(MediaType.APPLICATION_JSON_TYPE).build();
}
示例7: doGet
import org.codehaus.jackson.JsonGenerator; //導入方法依賴的package包/類
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws IOException {
resp.setContentType("application/json; charset=UTF-8");
StartupProgress prog = NameNodeHttpServer.getStartupProgressFromContext(
getServletContext());
StartupProgressView view = prog.createView();
JsonGenerator json = new JsonFactory().createJsonGenerator(resp.getWriter());
try {
json.writeStartObject();
json.writeNumberField(ELAPSED_TIME, view.getElapsedTime());
json.writeNumberField(PERCENT_COMPLETE, view.getPercentComplete());
json.writeArrayFieldStart(PHASES);
for (Phase phase: view.getPhases()) {
json.writeStartObject();
json.writeStringField(NAME, phase.getName());
json.writeStringField(DESC, phase.getDescription());
json.writeStringField(STATUS, view.getStatus(phase).toString());
json.writeNumberField(PERCENT_COMPLETE, view.getPercentComplete(phase));
json.writeNumberField(ELAPSED_TIME, view.getElapsedTime(phase));
writeStringFieldIfNotNull(json, FILE, view.getFile(phase));
writeNumberFieldIfDefined(json, SIZE, view.getSize(phase));
json.writeArrayFieldStart(STEPS);
for (Step step: view.getSteps(phase)) {
json.writeStartObject();
StepType type = step.getType();
if (type != null) {
json.writeStringField(NAME, type.getName());
json.writeStringField(DESC, type.getDescription());
}
json.writeNumberField(COUNT, view.getCount(phase, step));
writeStringFieldIfNotNull(json, FILE, step.getFile());
writeNumberFieldIfDefined(json, SIZE, step.getSize());
json.writeNumberField(TOTAL, view.getTotal(phase, step));
json.writeNumberField(PERCENT_COMPLETE, view.getPercentComplete(phase,
step));
json.writeNumberField(ELAPSED_TIME, view.getElapsedTime(phase, step));
json.writeEndObject();
}
json.writeEndArray();
json.writeEndObject();
}
json.writeEndArray();
json.writeEndObject();
} finally {
IOUtils.cleanup(LOG, json);
}
}
示例8: doGet
import org.codehaus.jackson.JsonGenerator; //導入方法依賴的package包/類
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws IOException {
resp.setContentType("application/json; charset=UTF-8");
StartupProgress prog = NameNodeHttpServer.getStartupProgressFromContext(
getServletContext());
StartupProgressView view = prog.createView();
JsonGenerator json = new JsonFactory().createJsonGenerator(resp.getWriter());
try {
json.writeStartObject();
json.writeNumberField(ELAPSED_TIME, view.getElapsedTime());
json.writeNumberField(PERCENT_COMPLETE, view.getPercentComplete());
json.writeArrayFieldStart(PHASES);
for (Phase phase: view.getPhases()) {
json.writeStartObject();
json.writeStringField(NAME, phase.getName());
json.writeStringField(STATUS, view.getStatus(phase).toString());
json.writeNumberField(PERCENT_COMPLETE, view.getPercentComplete(phase));
json.writeNumberField(ELAPSED_TIME, view.getElapsedTime(phase));
writeStringFieldIfNotNull(json, FILE, view.getFile(phase));
writeNumberFieldIfDefined(json, SIZE, view.getSize(phase));
json.writeArrayFieldStart(STEPS);
for (Step step: view.getSteps(phase)) {
json.writeStartObject();
StepType type = step.getType();
String name = type != null ? type.getName() : null;
writeStringFieldIfNotNull(json, NAME, name);
json.writeNumberField(COUNT, view.getCount(phase, step));
writeStringFieldIfNotNull(json, FILE, step.getFile());
writeNumberFieldIfDefined(json, SIZE, step.getSize());
json.writeNumberField(TOTAL, view.getTotal(phase, step));
json.writeNumberField(PERCENT_COMPLETE, view.getPercentComplete(phase,
step));
json.writeNumberField(ELAPSED_TIME, view.getElapsedTime(phase, step));
json.writeEndObject();
}
json.writeEndArray();
json.writeEndObject();
}
json.writeEndArray();
json.writeEndObject();
} finally {
IOUtils.cleanup(LOG, json);
}
}
示例9: serialize
import org.codehaus.jackson.JsonGenerator; //導入方法依賴的package包/類
@Override
public void serialize(LowLevelAbstractionDefinition value,
JsonGenerator jgen, SerializerProvider provider)
throws IOException, JsonProcessingException {
// start LLA
jgen.writeStartObject();
// general proposition definition stuff
provider.defaultSerializeField("@class", value.getClass(), jgen);
provider.defaultSerializeField("id", value.getId(), jgen);
provider.defaultSerializeField("displayName", value.getDisplayName(), jgen);
provider.defaultSerializeField("abbreviatedDisplayName", value.getAbbreviatedDisplayName(), jgen);
provider.defaultSerializeField("description", value.getDescription(), jgen);
provider.defaultSerializeField("algorithm", value.getAlgorithmId(), jgen);
provider.defaultSerializeField("inverseIsA", value.getInverseIsA(), jgen);
provider.defaultSerializeField("abstractedFrom", value.getAbstractedFrom(), jgen);
provider.defaultSerializeField("properties", value.getPropertyDefinitions(), jgen);
provider.defaultSerializeField("references", value.getReferenceDefinitions(), jgen);
provider.defaultSerializeField("sourceId", value.getSourceId(), jgen);
provider.defaultSerializeField("concatenable", value.isConcatenable(), jgen);
provider.defaultSerializeField("inDataSource", value.getInDataSource(), jgen);
provider.defaultSerializeField("gapFunction", value.getGapFunction(), jgen);
provider.defaultSerializeField("minimumDuration", value.getMinimumDuration(), jgen);
provider.defaultSerializeField("minimumDurationUnits", value.getMinimumDurationUnits(), jgen);
provider.defaultSerializeField("maximumDuration", value.getMaximumDuration(), jgen);
provider.defaultSerializeField("maximumDurationUnits", value.getMaximumDurationUnits(), jgen);
provider.defaultSerializeField("valueType", value.getValueType(), jgen);
provider.defaultSerializeField("skipStart", value.getSkipStart(), jgen);
provider.defaultSerializeField("skipEnd", value.getSkipEnd(), jgen);
provider.defaultSerializeField("skip", value.getSkip(), jgen);
provider.defaultSerializeField("maxOverlapping", value.getMaxOverlapping(), jgen);
provider.defaultSerializeField("slidingWindowWidthMode", value.getSlidingWindowWidthMode(), jgen);
provider.defaultSerializeField("maximumNumberOfValues", value.getMaximumNumberOfValues(), jgen);
provider.defaultSerializeField("minimumNumberOfValues", value.getMinimumNumberOfValues(), jgen);
provider.defaultSerializeField("minGapBetweenValues", value.getMinimumGapBetweenValues(), jgen);
provider.defaultSerializeField("minGapBetweenValuesUnits", value.getMinimumGapBetweenValuesUnits(), jgen);
provider.defaultSerializeField("maxGapBetweenValues", value.getMaximumGapBetweenValues(), jgen);
provider.defaultSerializeField("maxGapBetweenValuesUnits", value.getMaximumGapBetweenValuesUnits(), jgen);
provider.defaultSerializeField("context", value.getContextId(), jgen);
// value definitions
jgen.writeFieldName("values");
jgen.writeStartObject();
for (LowLevelAbstractionValueDefinition valDef : value.getValueDefinitions()) {
provider.defaultSerializeField("id", valDef.getId(), jgen);
provider.defaultSerializeField("value", valDef.getValue(), jgen);
jgen.writeArrayFieldStart("params");
for (String paramName : valDef.getParameters()) {
jgen.writeStartObject();
provider.defaultSerializeField("name", paramName, jgen);
provider.defaultSerializeField("value", valDef.getParameterValue(paramName), jgen);
provider.defaultSerializeField("comp", valDef.getParameterComp(paramName), jgen);
jgen.writeEndObject();
}
jgen.writeEndArray();
}
jgen.writeEndObject();
provider.defaultSerializeField("attributes", value.getAttributes(), jgen);
// end LLA
jgen.writeEndObject();
}