本文整理汇总了Java中com.fasterxml.jackson.core.JsonGenerator.configure方法的典型用法代码示例。如果您正苦于以下问题:Java JsonGenerator.configure方法的具体用法?Java JsonGenerator.configure怎么用?Java JsonGenerator.configure使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.fasterxml.jackson.core.JsonGenerator
的用法示例。
在下文中一共展示了JsonGenerator.configure方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: serialize
import com.fasterxml.jackson.core.JsonGenerator; //导入方法依赖的package包/类
@Override
public void serialize(OFFlowModMap fmm, JsonGenerator jGen, SerializerProvider serializer)
throws IOException, JsonProcessingException {
jGen.configure(Feature.WRITE_NUMBERS_AS_STRINGS, true); // IMHO this just looks nicer and is easier to read if everything is quoted
if (fmm == null) {
jGen.writeStartObject();
jGen.writeString("No flows have been added to the Static Flow Pusher.");
jGen.writeEndObject();
return;
}
Map<String, Map<String, OFFlowMod>> theMap = fmm.getMap();
jGen.writeStartObject();
if (theMap.keySet() != null) {
for (String dpid : theMap.keySet()) {
if (theMap.get(dpid) != null) {
jGen.writeArrayFieldStart(dpid);
for (String name : theMap.get(dpid).keySet()) {
jGen.writeStartObject();
jGen.writeFieldName(name);
OFFlowModSerializer.serializeFlowMod(jGen, theMap.get(dpid).get(name));
jGen.writeEndObject();
}
jGen.writeEndArray();
}
}
}
jGen.writeEndObject();
}
示例2: serialize
import com.fasterxml.jackson.core.JsonGenerator; //导入方法依赖的package包/类
@Override
public void serialize(SwitchPortBandwidth spb, JsonGenerator jGen, SerializerProvider serializer) throws IOException, JsonProcessingException {
jGen.configure(Feature.WRITE_NUMBERS_AS_STRINGS, true);
jGen.writeStartObject();
jGen.writeStringField("dpid", spb.getSwitchId().toString());
jGen.writeStringField("port", spb.getSwitchPort().toString());
jGen.writeStringField("updated", new Date(spb.getUpdateTime()).toString());
jGen.writeStringField("bits-per-second-rx", spb.getBitsPerSecondRx().getBigInteger().toString());
jGen.writeStringField("bits-per-second-tx", spb.getBitsPerSecondTx().getBigInteger().toString());
jGen.writeEndObject();
}
示例3: serializeFlowMod
import com.fasterxml.jackson.core.JsonGenerator; //导入方法依赖的package包/类
public static void serializeFlowMod(JsonGenerator jGen, OFFlowMod flowMod) throws IOException, JsonProcessingException {
jGen.configure(Feature.WRITE_NUMBERS_AS_STRINGS, true); // IMHO this just looks nicer and is easier to read if everything is quoted
jGen.writeStartObject();
jGen.writeStringField("version", flowMod.getVersion().toString()); // return the enum names
jGen.writeStringField("command", flowMod.getCommand().toString());
jGen.writeNumberField("cookie", flowMod.getCookie().getValue());
jGen.writeNumberField("priority", flowMod.getPriority());
jGen.writeNumberField("idleTimeoutSec", flowMod.getIdleTimeout());
jGen.writeNumberField("hardTimeoutSec", flowMod.getHardTimeout());
jGen.writeStringField("outPort", flowMod.getOutPort().toString());
switch (flowMod.getVersion()) {
case OF_10:
break;
case OF_11:
jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer11.toWireValue(flowMod.getFlags()));
jGen.writeNumberField("cookieMask", flowMod.getCookieMask().getValue());
jGen.writeStringField("outGroup", flowMod.getOutGroup().toString());
jGen.writeStringField("tableId", flowMod.getTableId().toString());
break;
case OF_12:
jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer12.toWireValue(flowMod.getFlags()));
jGen.writeNumberField("cookieMask", flowMod.getCookieMask().getValue());
jGen.writeStringField("outGroup", flowMod.getOutGroup().toString());
jGen.writeStringField("tableId", flowMod.getTableId().toString());
break;
case OF_13:
jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer13.toWireValue(flowMod.getFlags()));
jGen.writeNumberField("cookieMask", flowMod.getCookieMask().getValue());
jGen.writeStringField("outGroup", flowMod.getOutGroup().toString());
break;
case OF_14:
jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer14.toWireValue(flowMod.getFlags()));
jGen.writeNumberField("cookieMask", flowMod.getCookieMask().getValue());
jGen.writeStringField("outGroup", flowMod.getOutGroup().toString());
jGen.writeStringField("tableId", flowMod.getTableId().toString());
break;
default:
logger.error("Could not decode OFVersion {}", flowMod.getVersion());
break;
}
MatchSerializer.serializeMatch(jGen, flowMod.getMatch());
// handle OF1.1+ instructions with actions within
if (flowMod.getVersion() == OFVersion.OF_10) {
jGen.writeObjectFieldStart("actions");
OFActionListSerializer.serializeActions(jGen, flowMod.getActions());
jGen.writeEndObject();
} else {
OFInstructionListSerializer.serializeInstructionList(jGen, flowMod.getInstructions());
} // end not-empty instructions (else)
jGen.writeEndObject();
}