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


Java JsonGenerator.configure方法代码示例

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

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

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


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