本文整理汇总了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();
}
示例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();
}
示例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();
}
示例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
}
示例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);
}
}
示例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();
}
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
}
示例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();
}
示例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();
}
示例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();
}
}
示例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();
}