当前位置: 首页>>代码示例>>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;未经允许,请勿转载。