本文整理匯總了Java中com.fasterxml.jackson.core.JsonGenerator.writeNumberField方法的典型用法代碼示例。如果您正苦於以下問題:Java JsonGenerator.writeNumberField方法的具體用法?Java JsonGenerator.writeNumberField怎麽用?Java JsonGenerator.writeNumberField使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.fasterxml.jackson.core.JsonGenerator
的用法示例。
在下文中一共展示了JsonGenerator.writeNumberField方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: serialize
import com.fasterxml.jackson.core.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();
}
示例2: serialize
import com.fasterxml.jackson.core.JsonGenerator; //導入方法依賴的package包/類
@Override
public void serialize(MultipleFieldNamesModel object, JsonGenerator jsonGenerator, boolean writeStartAndEnd) throws IOException {
if (writeStartAndEnd) {
jsonGenerator.writeStartObject();
}
jsonGenerator.writeNumberField("possible_double_name_1", object.testDouble);
jsonGenerator.writeNumberField("possible_float_name_1", object.testFloat);
jsonGenerator.writeNumberField("possible_int_name_1", object.testInt);
jsonGenerator.writeNumberField("possible_long_name_1", object.testLong);
if (object.testString != null) {
jsonGenerator.writeStringField("possible_string_name_1", object.testString);
}
if (writeStartAndEnd) {
jsonGenerator.writeEndObject();
}
}
示例3: serialize
import com.fasterxml.jackson.core.JsonGenerator; //導入方法依賴的package包/類
@Override
public void serialize(JsonMeter jsonMeter,
JsonGenerator json,
SerializerProvider provider) throws IOException {
json.writeStartObject();
json.writeStringField("name", jsonMeter.name());
json.writeObjectField(timestampFieldname, jsonMeter.timestampAsDate());
Meter meter = jsonMeter.value();
json.writeNumberField("count", meter.getCount());
json.writeNumberField("m1_rate", meter.getOneMinuteRate() * rateFactor);
json.writeNumberField("m5_rate", meter.getFiveMinuteRate() * rateFactor);
json.writeNumberField("m15_rate", meter.getFifteenMinuteRate() * rateFactor);
json.writeNumberField("mean_rate", meter.getMeanRate() * rateFactor);
json.writeStringField("units", rateUnit);
addOneOpsMetadata(json);
json.writeEndObject();
}
示例4: serialize
import com.fasterxml.jackson.core.JsonGenerator; //導入方法依賴的package包/類
@Override
public void serialize(ImageIcon vi, JsonGenerator jgen, SerializerProvider provider)
throws IOException, JsonProcessingException {
synchronized (vi) {
BufferedImage v = new BufferedImage(
vi.getIconWidth(),
vi.getIconHeight(),
BufferedImage.TYPE_INT_RGB);
Graphics g = v.createGraphics();
// paint the Icon to the BufferedImage.
vi.paintIcon(null, g, 0, 0);
g.dispose();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ImageIO.write(v, "png", baos);
byte [] data = baos.toByteArray();
jgen.writeStartObject();
jgen.writeStringField("type", "ImageIcon");
jgen.writeObjectField("imageData", data);
jgen.writeNumberField("width", v.getWidth());
jgen.writeNumberField("height", v.getHeight());
jgen.writeEndObject();
}
}
示例5: serialize
import com.fasterxml.jackson.core.JsonGenerator; //導入方法依賴的package包/類
@Override
public void serialize(JsonGenerator generator) throws IOException {
generator.writeNumber(getCode());
generator.writeNumber(this.requestId);
if (this.subscriptionId != null || this.reason != null) {
generator.writeStartObject();
if (this.reason != null) {
generator.writeStringField("reason", this.reason);
}
if (this.subscriptionId != null) {
generator.writeNumberField("subscription", this.subscriptionId);
}
generator.writeEndObject();
}
}
示例6: serializeShard
import com.fasterxml.jackson.core.JsonGenerator; //導入方法依賴的package包/類
private static void serializeShard(@NotNull JsonGenerator jsonGenerator, @NotNull Base64.Encoder base64Encoder, @NotNull Map.Entry<Integer, EncryptedShard> shard) throws IOException {
jsonGenerator.writeStartObject();
jsonGenerator.writeNumberField(SHARD_POSITION_NAME, shard.getKey());
final String base64EncodedEncryptedShard = base64Encoder.encodeToString(shard.getValue().getEncryptedShardValue());
EncryptedShard encryptedShard = shard.getValue();
jsonGenerator.writeStringField(ENCRYPTED_SHARD_NAME, base64EncodedEncryptedShard);
final SymmetricEncryptionAlgorithm symmetricEncryptionAlgorithm = encryptedShard.getSymmetricEncryptionAlgorithm();
if (symmetricEncryptionAlgorithm != null) {
jsonGenerator.writeStringField(SYMMETRIC_ENCRYPTION_NAME, symmetricEncryptionAlgorithm.name());
}
final byte[] encryptedSymmetricKey = shard.getValue().getEncryptedSymmetricKey();
if (encryptedSymmetricKey != null) {
final String base64EncryptedKey = base64Encoder.encodeToString(encryptedSymmetricKey);
jsonGenerator.writeStringField(ENCRYPTED_SYMMETRIC_KEY_NAME, base64EncryptedKey);
}
jsonGenerator.writeEndObject();
}
示例7: serializeMeterFeaturesReply
import com.fasterxml.jackson.core.JsonGenerator; //導入方法依賴的package包/類
/***
* Serializes Meter Feature Reply
* @author Naveen
* @param meterFeaturesReplies
* @param jGen
* @throws IOException
* @throws JsonProcessingException
*/
public static void serializeMeterFeaturesReply(List<OFMeterFeaturesStatsReply> meterFeaturesReplies, JsonGenerator jGen) throws IOException, JsonProcessingException{
OFMeterFeaturesStatsReply meterFeaturesReply = meterFeaturesReplies.get(0);
jGen.writeStringField("version", meterFeaturesReply.getVersion().toString()); //return the enum name
OFMeterFeatures meterFeatures = meterFeaturesReply.getFeatures();
jGen.writeFieldName("meterFeatures");
jGen.writeStartObject();
jGen.writeNumberField("maxGroupsAll",meterFeatures.getMaxMeter());
jGen.writeNumberField("maxGroupsSelect",meterFeatures.getBandTypes());
jGen.writeNumberField("capabilities",meterFeatures.getCapabilities());
jGen.writeNumberField("maxGroupsIndirect",meterFeatures.getMaxBands());
jGen.writeNumberField("maxGroupsFf",meterFeatures.getMaxColor());
jGen.writeEndObject();//end of group Feature
}
示例8: serializeGroupFeaturesReply
import com.fasterxml.jackson.core.JsonGenerator; //導入方法依賴的package包/類
/***
* Serializes Group Feature Reply
* @author Naveen
* @param groupFeaturesReplies
* @param jGen
* @throws IOException
* @throws JsonProcessingException
*/
public static void serializeGroupFeaturesReply(List<OFGroupFeaturesStatsReply> groupFeaturesReplies, JsonGenerator jGen) throws IOException, JsonProcessingException{
OFGroupFeaturesStatsReply groupFeaturesReply = groupFeaturesReplies.get(0);
jGen.writeStringField("version", groupFeaturesReply.getVersion().toString()); //return the enum name
jGen.writeFieldName("groupFeatures");
jGen.writeStartObject();
jGen.writeNumberField("capabilities",groupFeaturesReply.getCapabilities());
jGen.writeNumberField("maxGroupsAll",groupFeaturesReply.getMaxGroupsAll());
jGen.writeNumberField("maxGroupsSelect",groupFeaturesReply.getMaxGroupsSelect());
jGen.writeNumberField("maxGroupsIndirect",groupFeaturesReply.getMaxGroupsIndirect());
jGen.writeNumberField("maxGroupsFf",groupFeaturesReply.getMaxGroupsFf());
jGen.writeNumberField("actionsAll",groupFeaturesReply.getActionsAll());
jGen.writeNumberField("actionsSelect",groupFeaturesReply.getActionsSelect());
jGen.writeNumberField("actionsIndirect",groupFeaturesReply.getActionsIndirect());
jGen.writeNumberField("actionsFf",groupFeaturesReply.getActionsFf());
jGen.writeEndObject();//end of group Feature
}
示例9: serialize
import com.fasterxml.jackson.core.JsonGenerator; //導入方法依賴的package包/類
@Override
public void serialize(StackTraceElement element, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException {
jsonGenerator.writeStartObject();
jsonGenerator.writeStringField("path", element.getFileName());
jsonGenerator.writeNumberField("line", element.getLineNumber());
jsonGenerator.writeStringField("label", element.getClassName() + "." + element.getMethodName());
jsonGenerator.writeEndObject();
}
示例10: serialize
import com.fasterxml.jackson.core.JsonGenerator; //導入方法依賴的package包/類
@Override
public void serialize(NonPrivateFieldsFieldDetectionPolicyModel object, JsonGenerator jsonGenerator, boolean writeStartAndEnd) throws IOException {
if (writeStartAndEnd) {
jsonGenerator.writeStartObject();
}
if (object.annotatedString != null) {
jsonGenerator.writeStringField("annotated_string", object.annotatedString);
}
jsonGenerator.writeNumberField("intToIgnoreForParse", object.intToIgnoreForParse);
final List<String> lslocalnonAnnotatedList = object.nonAnnotatedList;
if (lslocalnonAnnotatedList != null) {
jsonGenerator.writeFieldName("nonAnnotatedList");
jsonGenerator.writeStartArray();
for (String element1 : lslocalnonAnnotatedList) {
if (element1 != null) {
jsonGenerator.writeString(element1);
}
}
jsonGenerator.writeEndArray();
}
if (object.nonAnnotatedString != null) {
jsonGenerator.writeStringField("nonAnnotatedString", object.nonAnnotatedString);
}
jsonGenerator.writeNumberField("staticIntToInclude", object.staticIntToInclude);
jsonGenerator.writeNumberField("transientIntToInclude", object.transientIntToInclude);
if (writeStartAndEnd) {
jsonGenerator.writeEndObject();
}
}
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:30,代碼來源:NonPrivateFieldsFieldDetectionPolicyModel$$JsonObjectMapper.java
示例11: writeAsInteger
import com.fasterxml.jackson.core.JsonGenerator; //導入方法依賴的package包/類
/**
* Schrijf als integer.
* @param jgen json generator
* @param nodeName node naam
* @param waarde node waarde
* @throws IOException bij schrijf fouten
*/
static void writeAsInteger(final JsonGenerator jgen, final String nodeName, final Number waarde) throws IOException {
if (waarde == null) {
return;
}
if (waarde instanceof Long) {
jgen.writeNumberField(nodeName, waarde.longValue());
} else {
jgen.writeNumberField(nodeName, waarde.intValue());
}
}
示例12: writeJson
import com.fasterxml.jackson.core.JsonGenerator; //導入方法依賴的package包/類
public void writeJson(JsonGenerator generator) {
Objects.requireNonNull(generator);
try {
generator.writeStartObject();
generator.writeNumberField("offset", offset);
generator.writeNumberField("uncompressedLength", uncompressedLength);
generator.writeFieldName("stepValues");
writeStepValuesJson(generator);
generator.writeFieldName("stepLengths");
generator.writeArray(stepLengths, 0, stepLengths.length);
generator.writeEndObject();
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
示例13: serialize
import com.fasterxml.jackson.core.JsonGenerator; //導入方法依賴的package包/類
@Override
public void serialize(Index index, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException {
// jsonGenerator.writeStartObject();
jsonGenerator.writeObjectFieldStart("index");
jsonGenerator.writeNumberField("number", index.getIndex());
jsonGenerator.writeArrayFieldStart("numbers");
int[] numbers = index.getNumbers().stream().mapToInt(i -> i).toArray();
jsonGenerator.writeArray(numbers, 0, numbers.length);
jsonGenerator.writeEndArray();
jsonGenerator.writeEndObject();
// jsonGenerator.writeEndObject();
}
示例14: writeOptionalIntegerField
import com.fasterxml.jackson.core.JsonGenerator; //導入方法依賴的package包/類
public static void writeOptionalIntegerField(JsonGenerator jsonGenerator, String fieldName, int value) throws IOException {
Objects.requireNonNull(jsonGenerator);
Objects.requireNonNull(fieldName);
if (value != Integer.MAX_VALUE) {
jsonGenerator.writeNumberField(fieldName, value);
}
}
示例15: serializeMeterReply
import com.fasterxml.jackson.core.JsonGenerator; //導入方法依賴的package包/類
/***
* Serializes the Meter Statistics Reply
* @author Naveen
* @param meterReplies
* @param jGen
* @throws IOException
* @throws JsonProcessingException
*/
public static void serializeMeterReply(List<OFMeterStatsReply> meterReplies, JsonGenerator jGen) throws IOException, JsonProcessingException{
OFMeterStatsReply meterReply = meterReplies.get(0); // we will get only one meterReply and it will contains many OFMeterStatsEntry ?
jGen.writeStringField("version", meterReply.getVersion().toString()); //return the enum name
jGen.writeFieldName("meter");
jGen.writeStartArray();
for(OFMeterStats entry : meterReply.getEntries()) {
jGen.writeStartObject();
jGen.writeNumberField("meterId",entry.getMeterId());
jGen.writeNumberField("flowCount", entry.getFlowCount());
jGen.writeNumberField("packetInCount", entry.getPacketInCount().getValue());
jGen.writeNumberField("byteInCount", entry.getByteInCount().getValue());
jGen.writeFieldName("meterBandStats");
jGen.writeStartArray();
for(OFMeterBandStats bandStats : entry.getBandStats()) {
jGen.writeStartObject();
jGen.writeNumberField("packetBandCount", bandStats.getPacketBandCount().getValue());
jGen.writeNumberField("byteBandCount", bandStats.getByteBandCount().getValue());
jGen.writeEndObject();
}//End of for loop - bandStats
jGen.writeEndArray();
jGen.writeNumberField("durationSec", entry.getDurationSec());
jGen.writeNumberField("durationNsec", entry.getDurationNsec());
jGen.writeEndObject();
}//End of for loop - MeterStats
jGen.writeEndArray();
}