當前位置: 首頁>>代碼示例>>Java>>正文


Java JsonGenerator.writeStringField方法代碼示例

本文整理匯總了Java中com.fasterxml.jackson.core.JsonGenerator.writeStringField方法的典型用法代碼示例。如果您正苦於以下問題:Java JsonGenerator.writeStringField方法的具體用法?Java JsonGenerator.writeStringField怎麽用?Java JsonGenerator.writeStringField使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.fasterxml.jackson.core.JsonGenerator的用法示例。


在下文中一共展示了JsonGenerator.writeStringField方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: serialize

import com.fasterxml.jackson.core.JsonGenerator; //導入方法依賴的package包/類
@Override
public void serialize(ObfuscationLinkState oLinkState, JsonGenerator jGen,
                      SerializerProvider arg2) throws IOException,
                                              JsonProcessingException {
    jGen.writeStartObject();

    jGen.writeStringField("src", oLinkState.getLink().getSrc().toString());
    jGen.writeStringField("dst", oLinkState.getLink().getDst().toString());
    jGen.writeNumberField("srcPort", oLinkState.getLink().getSrcPort().getPortNumber());
    jGen.writeNumberField("dstPort", oLinkState.getLink().getDstPort().getPortNumber());
    
    jGen.writeFieldName("masks");
    jGen.writeStartArray();
    for (long dst: oLinkState.getInstalledMasks().keySet()) {
        jGen.writeStartObject();
    	//jGen.writeStringField("dst", dst.toString());
    	jGen.writeNumberField("observed_entropy", oLinkState.getObservedEntropy(dst));
    	jGen.writeNumberField("unicity_distance", oLinkState.getUnicityDistance(dst));
    	jGen.writeNumberField("flows", oLinkState.getNumberOfMaskUsages(dst));
    	jGen.writeEndObject();
    }
    jGen.writeEndArray();
    
    
    jGen.writeEndObject();
}
 
開發者ID:nsg-ethz,項目名稱:iTAP-controller,代碼行數:27,代碼來源:ObfuscationLinkStateJsonSerializer.java

示例2: serialize

import com.fasterxml.jackson.core.JsonGenerator; //導入方法依賴的package包/類
@Override
public void serialize(final T component,
                      final JsonGenerator jgen,
                      final SerializerProvider serializerProvider) throws IOException {
  jgen.writeStartObject();
  jgen.writeObjectField("type", component.getClass().getSimpleName());
  if (component.getLabel() != null) {
    jgen.writeStringField("label", component.getLabel());
  }
  jgen.writeBooleanField("enabled", component.isEnabled());
  if (component.getValue() != null) {
    jgen.writeObjectField("value", component.getValue());
  }
  writeSubclassFields(jgen, component);
  jgen.writeEndObject();
}
 
開發者ID:twosigma,項目名稱:beaker-notebook-archive,代碼行數:17,代碼來源:AbstractEasyFormComponentSerializer.java

示例3: serialize

import com.fasterxml.jackson.core.JsonGenerator; //導入方法依賴的package包/類
@Override
public void serialize(PropertyEntity value, JsonGenerator g, SerializerProvider provider) throws IOException {
    g.writeStartObject();
    g.writeStringField("id", value.getId());
    if (!EntityClassifierProcessor.isRelation(value)) {
        g.writeStringField("value", value.getValue());

        if (value.getHypernyms() != null && !value.getHypernyms().isEmpty()) {
            g.writeObjectField("hypernyms", value.getHypernyms());
        }
        if (value.getHyponyms() != null && !value.getHyponyms().isEmpty()) {
            g.writeObjectField("hyponyms", value.getHyponyms());
        }
        if (value.getSynonyms() != null && !value.getSynonyms().isEmpty()) {
            g.writeObjectField("synonyms", value.getSynonyms());
        }
    }
    g.writeEndObject();
}
 
開發者ID:Lambda-3,項目名稱:Stargraph,代碼行數:20,代碼來源:PropertySerializer.java

示例4: 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:nsg-ethz,項目名稱:iTAP-controller,代碼行數:25,代碼來源:StatsReplySerializer.java

示例5: toJsonString

import com.fasterxml.jackson.core.JsonGenerator; //導入方法依賴的package包/類
static String toJsonString(String summary, String detail, Markup markup, Revision nextRevision) {
    try {
        StringWriter stringWriter = new StringWriter();
        JsonGenerator jsonGenerator = Jackson.createPrettyGenerator(stringWriter);
        jsonGenerator.writeStartObject();
        jsonGenerator.writeStringField(FIELD_NAME_SUMMARY, summary);
        jsonGenerator.writeStringField(FIELD_NAME_DETAIL, detail);
        jsonGenerator.writeStringField(FIELD_NAME_MARKUP, markup.nameLowercased());
        jsonGenerator.writeStringField(FIELD_NAME_REVISION, nextRevision.text());
        jsonGenerator.writeEndObject();
        jsonGenerator.close();
        return stringWriter.toString();
    } catch (IOException e) {
        throw new StorageException("failed to generate a JSON string", e);
    }
}
 
開發者ID:line,項目名稱:centraldogma,代碼行數:17,代碼來源:CommitUtil.java

示例6: writeAdministratieveHandelingen

import com.fasterxml.jackson.core.JsonGenerator; //導入方法依賴的package包/類
private void writeAdministratieveHandelingen(final List<BlobViewObject> administratieveHandelingen, final JsonGenerator jgen) throws IOException {
    if (administratieveHandelingen != null && !administratieveHandelingen.isEmpty()) {
        jgen.writeObjectFieldStart(Element.ADMINISTRATIEVEHANDELING.getElementNaam());
        jgen.writeStringField(VELD_TYPE, "tabelGroep");
        jgen.writeArrayFieldStart("kolomtitels");
        jgen.writeString("Technisch ID");
        jgen.writeString(Element.ADMINISTRATIEVEHANDELING_SOORTNAAM.getElementNaam());
        jgen.writeString(Element.ADMINISTRATIEVEHANDELING_PARTIJCODE.getElementNaam());
        jgen.writeString(Element.ADMINISTRATIEVEHANDELING_TIJDSTIPREGISTRATIE.getElementNaam());
        jgen.writeString("Mutaties");
        jgen.writeString("$css");
        jgen.writeEndArray();
        jgen.writeArrayFieldStart("data");
        for (final BlobViewObject administratieveHandeling : administratieveHandelingen) {
            writeAdministratieveHandeling(administratieveHandeling, jgen);
        }
        jgen.writeEndArray();
        jgen.writeEndObject();
    }
}
 
開發者ID:MinBZK,項目名稱:OperatieBRP,代碼行數:21,代碼來源:PersoonDetailSerializer.java

示例7: serialize

import com.fasterxml.jackson.core.JsonGenerator; //導入方法依賴的package包/類
@Override
public void serialize(IOFSwitch sw, JsonGenerator jGen,
                      SerializerProvider serializer)
                              throws IOException, JsonProcessingException {
    jGen.writeStartObject();
    jGen.writeStringField("dpid",sw.getId().toString());
    serializeCapabilities(sw.getCapabilities(),jGen);
    serializeDescription(sw.getSwitchDescription(),jGen);
    serializeHarole(sw.getControllerRole(),jGen);
    serializeActions(sw.getActions(),jGen);
    serializeAttributes(sw.getAttributes(),jGen);
    serializePorts(sw.getPorts(),jGen);
    jGen.writeNumberField("buffers",sw.getBuffers());
    jGen.writeStringField("inetAddress",sw.getInetAddress().toString());
    jGen.writeNumberField("tables",sw.getNumTables());
    jGen.writeNumberField("connectedSince",sw.getConnectedSince().getTime());
    jGen.writeEndObject();
}
 
開發者ID:xuraylei,項目名稱:fresco_floodlight,代碼行數:19,代碼來源:IOFSwitchSerializer.java

示例8: serialize

import com.fasterxml.jackson.core.JsonGenerator; //導入方法依賴的package包/類
@Override
public void serialize(InstanceEntity value, JsonGenerator g, SerializerProvider provider) throws IOException {
    g.writeStartObject();
    g.writeStringField("id", value.getId());
    g.writeStringField("value", value.getValue());
    if (value.getOtherValues() != null && !value.getOtherValues().isEmpty()) {
        g.writeObjectField("otherValues", value.getOtherValues());
    }
    g.writeEndObject();
}
 
開發者ID:Lambda-3,項目名稱:Stargraph,代碼行數:11,代碼來源:InstanceSerializer.java

示例9: serialize

import com.fasterxml.jackson.core.JsonGenerator; //導入方法依賴的package包/類
@Override
public void serialize(JsonRpcResponse value, JsonGenerator gen, SerializerProvider provider)
		throws IOException {

	gen.writeStartObject();
	gen.writeStringField("jsonrpc", value.getJsonrpc());
	if (value.getError() != null) {
		gen.writeObjectField("error", value.getError());
		gen.writeStringField("id", null);
	} else {
		gen.writeStringField("id", value.getId());
		gen.writeObjectField("result", value.getResult());
	}
	gen.writeEndObject();
}
 
開發者ID:EonTechnology,項目名稱:server,代碼行數:16,代碼來源:JrpcService.java

示例10: serialize

import com.fasterxml.jackson.core.JsonGenerator; //導入方法依賴的package包/類
@Override
public void serialize(LBPool pool, JsonGenerator jGen,
                      SerializerProvider serializer) throws IOException,
                                              JsonProcessingException {
    jGen.writeStartObject();
    
    jGen.writeStringField("name", pool.name);
    jGen.writeStringField("id", pool.id);
    jGen.writeStringField("vipId", pool.vipId);

    for (int i=0; i<pool.members.size(); i++)
        jGen.writeStringField("pool", pool.members.get(i));

    jGen.writeEndObject();
}
 
開發者ID:nsg-ethz,項目名稱:iTAP-controller,代碼行數:16,代碼來源:LBPoolSerializer.java

示例11: serialize

import com.fasterxml.jackson.core.JsonGenerator; //導入方法依賴的package包/類
@Override
public void serialize(Date object, String fieldName, boolean writeFieldNameForObject, JsonGenerator jsonGenerator) throws IOException {
    if (fieldName != null && object != null) {
        jsonGenerator.writeStringField(fieldName, mDateFormat.get().format(object));
    } else if (object != null) {
        jsonGenerator.writeString(mDateFormat.get().format(object));
    } else {
        if (fieldName != null) {
            jsonGenerator.writeFieldName(fieldName);
        }
        jsonGenerator.writeNull();
    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:14,代碼來源:DateTypeConverter.java

示例12: writeSingleLocalization

import com.fasterxml.jackson.core.JsonGenerator; //導入方法依賴的package包/類
private void writeSingleLocalization(JsonGenerator jgen, Locale language, List<String> values) throws IOException {
  jgen.writeStartObject();
  jgen.writeStringField("@language", language.toLanguageTag());
  if (values.size() == 1) {
    jgen.writeStringField("@value", values.get(0));
  } else {
    jgen.writeArrayFieldStart("@value");
    for (String val : values) {
      jgen.writeString(val);
    }
    jgen.writeEndArray();
  }
  jgen.writeEndObject();
}
 
開發者ID:dbmdz,項目名稱:iiif-apis,代碼行數:15,代碼來源:PropertyValueSerializer.java

示例13: serialize

import com.fasterxml.jackson.core.JsonGenerator; //導入方法依賴的package包/類
@Override
public void serialize(PropertyBox box, JsonGenerator gen, SerializerProvider serializers)
		throws IOException, JsonProcessingException {
	gen.writeStartObject();

	for (Property<?> property : box) {
		if (property instanceof Path) {
			String name = ((Path<?>) property).getName();
			Object value = box.getValue(property);
			if (value != null) {
				if (TypeUtils.isDate(property.getType())) {
					gen.writeStringField(name, new SimpleDateFormat(ISO_DATE_FORMAT).format(value));
				} else if (TypeUtils.isCalendar(property.getType())) {
					gen.writeStringField(name,
							new SimpleDateFormat(ISO_DATE_FORMAT).format(((Calendar) value).getTime()));
				} else if (TypeUtils.isTemporal(property.getType())) {
					Temporal temporal = (Temporal) value;
					TemporalType temporalType = TemporalType.getTemporalType(temporal);
					switch (temporalType) {
					case DATE_TIME:
						gen.writeStringField(name, DateTimeFormatter.ISO_DATE_TIME.format(temporal));
						break;
					case TIME:
						gen.writeStringField(name, DateTimeFormatter.ISO_TIME.format(temporal));
						break;
					case DATE:
					default:
						gen.writeStringField(name, DateTimeFormatter.ISO_DATE.format(temporal));
						break;
					}
				} else {
					gen.writeObjectField(name, value);
				}
			}
		}
	}

	gen.writeEndObject();
}
 
開發者ID:holon-platform,項目名稱:holon-json,代碼行數:40,代碼來源:JacksonPropertyBoxSerializer.java

示例14: serialize

import com.fasterxml.jackson.core.JsonGenerator; //導入方法依賴的package包/類
@Override
public void serialize(BufferedImage v, JsonGenerator jgen, SerializerProvider provider)
    throws IOException, JsonProcessingException {
  synchronized(v) {
    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,代碼行數:16,代碼來源:BufferedImageSerializer.java

示例15: serialize

import com.fasterxml.jackson.core.JsonGenerator; //導入方法依賴的package包/類
@Override
public void serialize(LBVip vip, JsonGenerator jGen,
                      SerializerProvider serializer) throws IOException,
                                              JsonProcessingException {
    jGen.writeStartObject();
    
    jGen.writeStringField("name", vip.name);
    jGen.writeStringField("id", vip.id);
    jGen.writeStringField("address", String.valueOf(vip.address));
    jGen.writeStringField("protocol", Byte.toString(vip.protocol));
    jGen.writeStringField("port", Short.toString(vip.port));

    jGen.writeEndObject();
}
 
開發者ID:xuraylei,項目名稱:fresco_floodlight,代碼行數:15,代碼來源:LBVipSerializer.java


注:本文中的com.fasterxml.jackson.core.JsonGenerator.writeStringField方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。