当前位置: 首页>>代码示例>>Java>>正文


Java JsonGenerator.writeNumberField方法代码示例

本文整理汇总了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();
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:26,代码来源:CumulativeTimeBucketJSONSerializer.java

示例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();
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:17,代码来源:MultipleFieldNamesModel$$JsonObjectMapper.java

示例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();
}
 
开发者ID:oneops,项目名称:oneops,代码行数:18,代码来源:MetricsElasticsearchModule.java

示例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();
  }
}
 
开发者ID:twosigma,项目名称:beaker-notebook-archive,代码行数:26,代码来源:ImageIconSerializer.java

示例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();
	}
}
 
开发者ID:ralscha,项目名称:wamp2spring,代码行数:17,代码来源:UnsubscribedMessage.java

示例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();
}
 
开发者ID:mgrand,项目名称:crypto-shuffle,代码行数:18,代码来源:JsonUtil.java

示例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
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:25,代码来源:StatsReplySerializer.java

示例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
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:28,代码来源:StatsReplySerializer.java

示例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();
}
 
开发者ID:aws,项目名称:aws-xray-sdk-java,代码行数:9,代码来源:StackTraceElementSerializer.java

示例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());
    }
}
 
开发者ID:MinBZK,项目名称:OperatieBRP,代码行数:18,代码来源:JsonUtils.java

示例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);
    }
}
 
开发者ID:powsybl,项目名称:powsybl-core,代码行数:16,代码来源:AbstractCompressedArrayChunk.java

示例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();
    }
 
开发者ID:thelittlehawk,项目名称:CSIS280,代码行数:13,代码来源:IndexSerializer.java

示例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);
    }
}
 
开发者ID:powsybl,项目名称:powsybl-core,代码行数:9,代码来源:JsonUtil.java

示例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();
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:36,代码来源:StatsReplySerializer.java


注:本文中的com.fasterxml.jackson.core.JsonGenerator.writeNumberField方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。