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


Java JsonGenerator.writeObjectFieldStart方法代码示例

本文整理汇总了Java中com.fasterxml.jackson.core.JsonGenerator.writeObjectFieldStart方法的典型用法代码示例。如果您正苦于以下问题:Java JsonGenerator.writeObjectFieldStart方法的具体用法?Java JsonGenerator.writeObjectFieldStart怎么用?Java JsonGenerator.writeObjectFieldStart使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.fasterxml.jackson.core.JsonGenerator的用法示例。


在下文中一共展示了JsonGenerator.writeObjectFieldStart方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: OutputStreamDemo

import com.fasterxml.jackson.core.JsonGenerator; //导入方法依赖的package包/类
public static void OutputStreamDemo() throws IOException {
    String out = "";
    JsonFactory f = new JsonFactory();
    FileOutputStream fos = new FileOutputStream(new File("user.out.json"));
    JsonGenerator g = f.createGenerator(fos);

    g.writeStartObject();
    g.writeObjectFieldStart("name");
    g.writeStringField("first", "BorLion");
    g.writeStringField("last", "Zhu");
    g.writeEndObject(); // for field 'name'
    g.writeStringField("gender", "MALE");
    g.writeBooleanField("verified", true);
    g.writeBinaryField("userImage", "Rm9vYmFyIQ==".getBytes());
    g.writeEndObject();
    g.writeRaw('\n');
    g.close();

}
 
开发者ID:zhubl,项目名称:planless,代码行数:20,代码来源:Main.java

示例2: serialize

import com.fasterxml.jackson.core.JsonGenerator; //导入方法依赖的package包/类
@Override
public void serialize(JsonGenerator generator) throws IOException {
	generator.writeNumber(getCode());
	generator.writeString(this.realm);
	generator.writeStartObject();
	generator.writeObjectFieldStart("roles");
	for (WampRole wampRole : this.roles) {
		generator.writeObjectFieldStart(wampRole.getRole());
		if (wampRole.hasFeatures()) {
			generator.writeObjectFieldStart("features");
			for (String feature : wampRole.getFeatures()) {
				generator.writeBooleanField(feature, true);
			}
			generator.writeEndObject();
		}
		generator.writeEndObject();
	}
	generator.writeEndObject();
	generator.writeEndObject();
}
 
开发者ID:ralscha,项目名称:wamp2spring,代码行数:21,代码来源:HelloMessage.java

示例3: serialize

import com.fasterxml.jackson.core.JsonGenerator; //导入方法依赖的package包/类
@Override
public void serialize(LinksInformation value, JsonGenerator gen, SerializerProvider serializers)
		throws IOException {

	gen.writeStartObject();

	BeanInformation info = BeanInformation.get(value.getClass());

	for (String attrName : info.getAttributeNames()) {
		BeanAttributeInformation attribute = info.getAttribute(attrName);
		Object linkValue = attribute.getValue(value);
		if (linkValue != null) {
			gen.writeObjectFieldStart(attrName);
			if (linkValue instanceof String) {
				gen.writeStringField(SerializerUtil.HREF, linkValue.toString());
			}
			else {
				gen.writeObject(linkValue);
			}
			gen.writeEndObject();
		}
	}

	gen.writeEndObject();

}
 
开发者ID:crnk-project,项目名称:crnk-framework,代码行数:27,代码来源:LinksInformationSerializer.java

示例4: writeGroep

import com.fasterxml.jackson.core.JsonGenerator; //导入方法依赖的package包/类
private void writeGroep(final BlobViewGroep groep, final JsonGenerator jgen) throws IOException {
    jgen.writeObjectFieldStart(groep.getElement().getElementNaam());
    JsonUtils.writeAsString(jgen, TYPE, GROEP);
    JsonUtils.writeAsString(jgen, SLEUTEL, groep.getElement().getElementNaam());

    // Actuele data
    final List<BlobViewRecord> records = new ArrayList<>(groep.getRecords());
    final BlobViewRecord actueelRecord = extractActueelRecord(records);
    if (actueelRecord != null) {
        writeRecordData(actueelRecord, jgen);
    }

    // Mutaties als tabel
    jgen.writeObjectFieldStart("Mutaties voor " + groep.getElement().getElementNaam());
    JsonUtils.writeAsString(jgen, INDEX_OBJECT, String.valueOf(COUNTER.incrementAndGet()));
    jgen.writeStringField(TYPE, "tabel");
    writeHistorieRecordKop(jgen, groep);

    jgen.writeArrayFieldStart("data");
    writeRecords(groep, records, jgen);

    jgen.writeEndArray();
    jgen.writeEndObject();
    jgen.writeEndObject();
}
 
开发者ID:MinBZK,项目名称:OperatieBRP,代码行数:26,代码来源:ObjectSerializer.java

示例5: maakCssLinkObject

import com.fasterxml.jackson.core.JsonGenerator; //导入方法依赖的package包/类
private void maakCssLinkObject(final ActieType actieType, final BlobViewObject actie, final StringBuilder ccsClassBuilder, final JsonGenerator jgen)
        throws IOException {
    if (actie != null) {
        final BlobViewObject administratieveHandeling = actie.getParent();

        ccsClassBuilder.append(BRP_MARKEER);
        ccsClassBuilder.append(administratieveHandeling.getObjectsleutel());
        ccsClassBuilder.append(" ");
        jgen.writeObjectFieldStart(actieType.getOmschrijving());
        jgen.writeStringField(TYPE, CSS_LINK);
        jgen.writeStringField(LINK_TEKST, "Ja (actie " + actie.getObjectsleutel() + ")");
        jgen.writeStringField(LINK, BRP_MARKEER + administratieveHandeling.getObjectsleutel());
        jgen.writeEndObject();
    } else {
        jgen.writeObjectFieldStart(actieType.getOmschrijving());
        jgen.writeStringField(TYPE, CSS_LINK);
        jgen.writeStringField(LINK_TEKST, "Nee");
        jgen.writeStringField(LINK, "");
        jgen.writeEndObject();
    }
}
 
开发者ID:MinBZK,项目名称:OperatieBRP,代码行数:22,代码来源:ObjectSerializer.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: serializeAggregateReply

import com.fasterxml.jackson.core.JsonGenerator; //导入方法依赖的package包/类
public static void serializeAggregateReply(List<OFAggregateStatsReply> aggregateReplies, JsonGenerator jGen) throws IOException, JsonProcessingException{
	OFAggregateStatsReply aggregateReply = aggregateReplies.get(0); // There are only one aggregateReply from the switch
	jGen.writeObjectFieldStart("aggregate"); 
	jGen.writeStringField("version", aggregateReply.getVersion().toString()); //return the enum name
	jGen.writeNumberField("flowCount", aggregateReply.getFlowCount());
	jGen.writeNumberField("packetCount", aggregateReply.getPacketCount().getValue());
	jGen.writeNumberField("byteCount", aggregateReply.getByteCount().getValue());
	switch (aggregateReply.getVersion()) {
	case OF_10:
		jGen.writeNumberField("flags", OFStatsReplyFlagsSerializerVer10.toWireValue(aggregateReply.getFlags()));
		break;
	case OF_11:
		jGen.writeNumberField("flags", OFStatsReplyFlagsSerializerVer11.toWireValue(aggregateReply.getFlags()));
		break;
	case OF_12:
		jGen.writeNumberField("flags", OFStatsReplyFlagsSerializerVer12.toWireValue(aggregateReply.getFlags()));
		break;
	case OF_13:
		jGen.writeNumberField("flags", OFStatsReplyFlagsSerializerVer13.toWireValue(aggregateReply.getFlags()));
		break;
	case OF_14:
		jGen.writeNumberField("flags", OFStatsReplyFlagsSerializerVer14.toWireValue(aggregateReply.getFlags()));
		break;
	default:
		break;
	}
	jGen.writeEndObject(); // end match
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:29,代码来源:StatsReplySerializer.java

示例8: serializeLink

import com.fasterxml.jackson.core.JsonGenerator; //导入方法依赖的package包/类
public void serializeLink(JsonGenerator gen, String fieldName, String url) throws IOException {
	if (serializeLinksAsObjects) {
		gen.writeObjectFieldStart(fieldName);
		gen.writeStringField(HREF, url);
		gen.writeEndObject();
	}
	else {
		gen.writeStringField(fieldName, url);
	}
}
 
开发者ID:crnk-project,项目名称:crnk-framework,代码行数:11,代码来源:SerializerUtil.java

示例9: writeAboutLink

import com.fasterxml.jackson.core.JsonGenerator; //导入方法依赖的package包/类
private static void writeAboutLink(ErrorData errorData, JsonGenerator gen) throws IOException {
	if (errorData.getAboutLink() != null) {
		SerializerUtil serializerUtil = DocumentMapperUtil.getSerializerUtil();

		gen.writeObjectFieldStart(LINKS);
		serializerUtil.serializeLink(gen, ABOUT_LINK, errorData.getAboutLink());
		gen.writeEndObject();
	}
}
 
开发者ID:crnk-project,项目名称:crnk-framework,代码行数:10,代码来源:ErrorDataSerializer.java

示例10: serializeDescReply

import com.fasterxml.jackson.core.JsonGenerator; //导入方法依赖的package包/类
public static void serializeDescReply(List<OFDescStatsReply> descReplies, JsonGenerator jGen) throws IOException, JsonProcessingException{
	OFDescStatsReply descReply = descReplies.get(0); // There is only one descReply from the switch
	jGen.writeObjectFieldStart("desc"); 
	jGen.writeStringField("version", descReply.getVersion().toString()); //return the enum name
	jGen.writeStringField("manufacturerDescription", descReply.getMfrDesc()); 
	jGen.writeStringField("hardwareDescription", descReply.getHwDesc()); 
	jGen.writeStringField("softwareDescription", descReply.getSwDesc()); 
	jGen.writeStringField("serialNumber", descReply.getSerialNum()); 
	jGen.writeStringField("datapathDescription", descReply.getDpDesc()); 
	jGen.writeEndObject(); // end match
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:12,代码来源:StatsReplySerializer.java

示例11: serialize

import com.fasterxml.jackson.core.JsonGenerator; //导入方法依赖的package包/类
@Override
public void serialize(BulkIndexOperationHeader bulkIndexOperationHeader, JsonGenerator json, SerializerProvider provider) throws IOException {
    json.writeStartObject();
    json.writeObjectFieldStart("index");
    if (bulkIndexOperationHeader.index != null) {
        json.writeStringField("_index", bulkIndexOperationHeader.index);
    }
    if (bulkIndexOperationHeader.type != null) {
        json.writeStringField("_type", bulkIndexOperationHeader.type);
    }
    json.writeEndObject();
    json.writeEndObject();
}
 
开发者ID:oneops,项目名称:oneops,代码行数:14,代码来源:MetricsElasticsearchModule.java

示例12: writeObjecten

import com.fasterxml.jackson.core.JsonGenerator; //导入方法依赖的package包/类
/**
 * Schrijf objecten.
 * @param element element
 * @param objecten objecten
 * @param jgen json generator
 * @throws IOException bij fouten
 */
public void writeObjecten(final Element element, final Collection<BlobViewObject> objecten, final JsonGenerator jgen) throws IOException {
    if (objecten != null && !objecten.isEmpty()) {
        jgen.writeObjectFieldStart(element.getElementNaam());
        JsonUtils.writeAsString(jgen, TYPE, GROEP);
        jgen.writeArrayFieldStart(element.getElementNaam());
        for (final BlobViewObject object : objecten) {
            jgen.writeStartObject();
            writeObject(object, jgen);
            jgen.writeEndObject();
        }
        jgen.writeEndArray();
        jgen.writeEndObject();
    }
}
 
开发者ID:MinBZK,项目名称:OperatieBRP,代码行数:22,代码来源:ObjectSerializer.java

示例13: writeRecords

import com.fasterxml.jackson.core.JsonGenerator; //导入方法依赖的package包/类
private void writeRecords(final BlobViewGroep groep, final Collection<BlobViewRecord> records, final JsonGenerator jgen) throws IOException {
    for (final BlobViewRecord record : records) {
        jgen.writeStartObject();
        JsonUtils.writeAsString(jgen, INDEX_OBJECT, String.valueOf(COUNTER.incrementAndGet()));
        writeHistorieRecord(groep, record, jgen);

        jgen.writeObjectFieldStart(DETAIL);

        JsonUtils.writeAsInteger(jgen, TECHNISCH_ID, record.getVoorkomensleutel());
        writeRecordData(record, jgen);
        jgen.writeEndObject();
        jgen.writeEndObject();
    }
}
 
开发者ID:MinBZK,项目名称:OperatieBRP,代码行数:15,代码来源:ObjectSerializer.java

示例14: writeAdministratieveHandeling

import com.fasterxml.jackson.core.JsonGenerator; //导入方法依赖的package包/类
private void writeAdministratieveHandeling(final BlobViewObject administratieveHandeling, final JsonGenerator jgen) throws IOException {
    jgen.writeStartObject();

    jgen.writeObjectFieldStart("Technisch ID");
    jgen.writeStringField(VELD_TYPE, "link");
    jgen.writeStringField("linkTekst", String.valueOf(administratieveHandeling.getObjectsleutel()));
    jgen.writeStringField("link", "administratievehandelingen/" + administratieveHandeling.getObjectsleutel());
    jgen.writeStringField("linkId", UUID.randomUUID().toString());
    jgen.writeEndObject();
    final BlobViewGroep identiteitGroep = administratieveHandeling.getGroep(Element.ADMINISTRATIEVEHANDELING_IDENTITEIT);
    final BlobViewRecord identiteit = identiteitGroep.getRecords().iterator().next();

    attribuutSerializer.writeAttribuut(
            Element.ADMINISTRATIEVEHANDELING_SOORTNAAM,
            identiteit.getAttributen().get(Element.ADMINISTRATIEVEHANDELING_SOORTNAAM),
            jgen);
    attribuutSerializer.writeAttribuut(
            Element.ADMINISTRATIEVEHANDELING_PARTIJCODE,
            identiteit.getAttributen().get(Element.ADMINISTRATIEVEHANDELING_PARTIJCODE),
            jgen);
    attribuutSerializer.writeAttribuut(
            Element.ADMINISTRATIEVEHANDELING_TIJDSTIPREGISTRATIE,
            identiteit.getAttributen().get(Element.ADMINISTRATIEVEHANDELING_TIJDSTIPREGISTRATIE),
            jgen);

    jgen.writeObjectFieldStart("Mutaties");
    jgen.writeStringField(VELD_TYPE, "cssLink");
    jgen.writeStringField("linkTekst", "Zie wijzigingen");
    jgen.writeStringField("link", "brp-markeer-" + administratieveHandeling.getObjectsleutel());
    jgen.writeEndObject();
    final StringBuilder cssBuilder = new StringBuilder("brp-markeer-");
    cssBuilder.append(administratieveHandeling.getObjectsleutel());
    jgen.writeStringField("$css", cssBuilder.toString());

    jgen.writeEndObject();
}
 
开发者ID:MinBZK,项目名称:OperatieBRP,代码行数:37,代码来源:PersoonDetailSerializer.java

示例15: 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:nsg-ethz,项目名称:iTAP-controller,代码行数:57,代码来源:OFFlowModSerializer.java


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