當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。