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