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


Java JsonGenerator類代碼示例

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


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

示例1: writeMetaData

import com.fasterxml.jackson.core.JsonGenerator; //導入依賴的package包/類
@Override
public void writeMetaData(OutputStream out, ResourceWithMetadata resource, Map<String, ResourceWithMetadata> allApiResources) throws IOException
{
    
    final Object result = processResult(resource,allApiResources);

    assistant.getJsonHelper().withWriter(out, new Writer()
    {
        @Override
        public void writeContents(JsonGenerator generator, ObjectMapper objectMapper)
                    throws JsonGenerationException, JsonMappingException, IOException
        {           
           objectMapper.writeValue(generator, result);
        }
    });
}
 
開發者ID:Alfresco,項目名稱:alfresco-remote-api,代碼行數:17,代碼來源:WebScriptOptionsMetaData.java

示例2: serialize

import com.fasterxml.jackson.core.JsonGenerator; //導入依賴的package包/類
@Override
public void serialize(CategoryLines categoryLines,
                      JsonGenerator jgen,
                      SerializerProvider provider) throws
                                                   IOException,
                                                   JsonProcessingException {
  jgen.writeStartObject();

  super.serialize(categoryLines, jgen, provider);

  if (categoryLines.getWidth() != null) {
    jgen.writeObjectField("width", categoryLines.getWidth());
  }
  if (categoryLines.getStyles() != null) {
    jgen.writeObjectField("styles", categoryLines.getStyles());
  } else {
    jgen.writeObjectField("style", categoryLines.getStyle().toString());
  }
  if (categoryLines.getInterpolation() != null) {
    jgen.writeObjectField("interpolation", categoryLines.getInterpolation());
  }

  jgen.writeEndObject();
}
 
開發者ID:twosigma,項目名稱:beaker-notebook-archive,代碼行數:25,代碼來源:CategoryLinesSerializer.java

示例3: writeHistorieRecordKop

import com.fasterxml.jackson.core.JsonGenerator; //導入依賴的package包/類
private void writeHistorieRecordKop(final JsonGenerator jgen, final BlobViewGroep groep) throws IOException {
    jgen.writeArrayFieldStart("kolomtitels");
    jgen.writeString(INDEX_OBJECT);
    if (isFormeel(groep.getElement())) {
        jgen.writeString(TIJDSTIP_REGISTRATIE);
        jgen.writeString(TIJDSTIP_VERVAL);
        jgen.writeString(NADERE_AANDUIDING_VERVAL);
        jgen.writeString(ActieType.INHOUD.getOmschrijving());
        jgen.writeString(ActieType.VERVAL.getOmschrijving());
        jgen.writeString(CSS);

    } else if (isMaterieel(groep.getElement())) {
        jgen.writeString(DATUM_INGANG_GELDIGHEID);
        jgen.writeString(DATUM_EINDE_GELDIGHEID);
        jgen.writeString(TIJDSTIP_REGISTRATIE);
        jgen.writeString(TIJDSTIP_VERVAL);
        jgen.writeString(NADERE_AANDUIDING_VERVAL);
        jgen.writeString(ActieType.INHOUD.getOmschrijving());
        jgen.writeString(ActieType.AANPASSING.getOmschrijving());
        jgen.writeString(ActieType.VERVAL.getOmschrijving());
        jgen.writeString(CSS);
    }
    jgen.writeString(DETAIL);
    jgen.writeEndArray();
}
 
開發者ID:MinBZK,項目名稱:OperatieBRP,代碼行數:26,代碼來源:ObjectSerializer.java

示例4: serialize

import com.fasterxml.jackson.core.JsonGenerator; //導入依賴的package包/類
protected void serialize(T chart, JsonGenerator jgen) throws IOException {

    super.serialize(chart, jgen);

    String type = chart.getClass().getSimpleName();
    if ("SimpleTimePlot".equals(type)){
      jgen.writeObjectField("type", "TimePlot");
    }else {
      jgen.writeObjectField("type", type);
    }

    jgen.writeObjectField(INIT_WIDTH, chart.getInitWidth());
    jgen.writeObjectField(INIT_HEIGHT, chart.getInitHeight());
    jgen.writeObjectField(CHART_TITLE, chart.getTitle());
    jgen.writeObjectField(SHOW_LEGEND, chart.getShowLegend());
    jgen.writeObjectField(USE_TOOL_TIP, chart.getUseToolTip());
    jgen.writeObjectField(LEGEND_POSITION, chart.getLegendPosition());
    jgen.writeObjectField("legend_layout", chart.getLegendLayout());
    jgen.writeObjectField("custom_styles", chart.getCustomStyles());
    jgen.writeObjectField("element_styles", chart.getElementStyles());
  }
 
開發者ID:twosigma,項目名稱:beaker-notebook-archive,代碼行數:22,代碼來源:ChartSerializer.java

示例5: configureFeature

import com.fasterxml.jackson.core.JsonGenerator; //導入依賴的package包/類
private void configureFeature(ObjectMapper objectMapper, Object feature, boolean enabled) {
	if (feature instanceof JsonParser.Feature) {
		objectMapper.configure((JsonParser.Feature) feature, enabled);
	}
	else if (feature instanceof JsonGenerator.Feature) {
		objectMapper.configure((JsonGenerator.Feature) feature, enabled);
	}
	else if (feature instanceof SerializationFeature) {
		objectMapper.configure((SerializationFeature) feature, enabled);
	}
	else if (feature instanceof DeserializationFeature) {
		objectMapper.configure((DeserializationFeature) feature, enabled);
	}
	else if (feature instanceof MapperFeature) {
		objectMapper.configure((MapperFeature) feature, enabled);
	}
	else {
		throw new FatalBeanException("Unknown feature class: " + feature.getClass().getName());
	}
}
 
開發者ID:JetBrains,項目名稱:teamcity-hashicorp-vault-plugin,代碼行數:21,代碼來源:Jackson2ObjectMapperBuilder.java

示例6: serialize

import com.fasterxml.jackson.core.JsonGenerator; //導入依賴的package包/類
@Override
public void serialize(JsonMeter jsonMeter,
                      JsonGenerator json,
                      SerializerProvider provider) throws IOException {
    json.writeStartObject();
    json.writeStringField("name", jsonMeter.name());
    json.writeObjectField(timestampFieldname, jsonMeter.timestampAsDate());
    Meter meter = jsonMeter.value();
    json.writeNumberField("count", meter.getCount());
    json.writeNumberField("m1_rate", meter.getOneMinuteRate() * rateFactor);
    json.writeNumberField("m5_rate", meter.getFiveMinuteRate() * rateFactor);
    json.writeNumberField("m15_rate", meter.getFifteenMinuteRate() * rateFactor);
    json.writeNumberField("mean_rate", meter.getMeanRate() * rateFactor);
    json.writeStringField("units", rateUnit);
    addOneOpsMetadata(json);
    json.writeEndObject();
}
 
開發者ID:oneops,項目名稱:oneops,代碼行數:18,代碼來源:MetricsElasticsearchModule.java

示例7: serialize

import com.fasterxml.jackson.core.JsonGenerator; //導入依賴的package包/類
@Override
public void serialize(final TradingStatusType value, final JsonGenerator gen, final SerializerProvider serializers) throws IOException {
    if (value == null || value == TradingStatusType.UNKNOWN) {
        gen.writeNull();
        return;
    }

    switch (value) {
        case TRADING_HALTED:
            gen.writeString("H");
            break;
        case TRADING_HALT_RELEASED_INTO_ORDER_ACCEPTANCE_PERIOD:
            gen.writeString("O");
            break;
        case TRADING_PAUSED_AND_ORDER_ACCEPTANCE_PERIOD_ON_IEX:
            gen.writeString("P");
            break;
        case TRADING_ON_IEX:
            gen.writeString("T");
            break;
        default:
            gen.writeNull();
            break;
    }
}
 
開發者ID:WojciechZankowski,項目名稱:iextrading4j,代碼行數:26,代碼來源:TradingStatusTypeSerializer.java

示例8: _testFailOnWritingStringFromReaderWithTooFewCharacters

import com.fasterxml.jackson.core.JsonGenerator; //導入依賴的package包/類
private void _testFailOnWritingStringFromReaderWithTooFewCharacters(JsonFactory f, boolean useReader) throws Exception{
    JsonGenerator gen;
    ByteArrayOutputStream bout = new ByteArrayOutputStream();
    if (useReader) {
        gen = f.createGenerator(ObjectWriteContext.empty(), new OutputStreamWriter(bout, "UTF-8"));
    } else {
        gen = f.createGenerator(ObjectWriteContext.empty(), bout, JsonEncoding.UTF8);
    }
    gen.writeStartObject();

    try {
        String testStr = "aaaaaaaaa";
        StringReader reader = new StringReader(testStr);
        gen.writeFieldName("a");
        gen.writeString(reader, testStr.length() + 1);
        gen.flush();
        String json = bout.toString("UTF-8");
        fail("Should not have let "+gen.getClass().getName()+".writeString() ': output = "+json);
    } catch (JsonProcessingException e) {
        verifyException(e, "Didn't read enough from reader");
    }
    gen.close();
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:24,代碼來源:GeneratorFailFromReaderTest.java

示例9: serialize

import com.fasterxml.jackson.core.JsonGenerator; //導入依賴的package包/類
@Override
public void serialize(JsonGenerator generator) throws IOException {
	generator.writeNumber(getCode());
	generator.writeNumber(this.sessionId);

	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();

	if (this.realm != null) {
		generator.writeStringField("realm", this.realm);
	}
	generator.writeEndObject();
}
 
開發者ID:ralscha,項目名稱:wamp2spring,代碼行數:27,代碼來源:WelcomeMessage.java

示例10: serialize

import com.fasterxml.jackson.core.JsonGenerator; //導入依賴的package包/類
@Override
public void serialize(final BerichtListView value, final JsonGenerator jgen, final SerializerProvider provider) throws IOException {
    jgen.writeStartObject();
    if (value.getBericht() != null) {
        JsonUtils.writeAsInteger(jgen, BerichtModule.ID, ObjectUtils.getWaarde(value, "bericht.id"));
        JsonUtils.writeAsInteger(jgen, BerichtModule.SOORT, ObjectUtils.getWaarde(value, "bericht.soortBericht.id"));
        JsonUtils.writeAsInteger(jgen, BerichtModule.ZENDENDE_PARTIJ, ObjectUtils.getWaarde(value, "bericht.zendendePartij"));
        JsonUtils.writeAsInteger(jgen, BerichtModule.ONTVANGENDE_PARTIJ, ObjectUtils.getWaarde(value, "bericht.ontvangendePartij"));
        JsonUtils.writeAsString(jgen, BerichtModule.REFERENTIENUMMER, value.getBericht().getReferentieNummer());
        JsonUtils.writeAsString(jgen, BerichtModule.CROSS_REFERENTIENUMMER, value.getBericht().getCrossReferentieNummer());
        JsonUtils.writeAsString(jgen, BerichtModule.VERZENDDATUM, ObjectUtils.getGeformateerdeWaarde(value, "bericht.datumTijdVerzending", sdf));
        JsonUtils.writeAsString(jgen, BerichtModule.ONTVANGSTDATUM, ObjectUtils.getGeformateerdeWaarde(value, "bericht.datumTijdOntvangst", sdf));
        JsonUtils.writeAsInteger(jgen, BerichtModule.SOORT_SYNCHRONISATIE, ObjectUtils.getWaarde(value, "bericht.soortSynchronisatie.id"));
        JsonUtils.writeAsInteger(jgen, BerichtModule.VERWERKINGSWIJZE, ObjectUtils.getWaarde(value, "bericht.verwerkingswijze.id"));
        JsonUtils.writeAsInteger(jgen, BerichtModule.BIJHOUDING, ObjectUtils.getWaarde(value, "bericht.bijhoudingResultaat.id"));
    }
    jgen.writeEndObject();

}
 
開發者ID:MinBZK,項目名稱:OperatieBRP,代碼行數:20,代碼來源:BerichtListSerializer.java

示例11: 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

示例12: serialize

import com.fasterxml.jackson.core.JsonGenerator; //導入依賴的package包/類
@Override
public void serialize(final Version value, final JsonGenerator jgen, final SerializerProvider provider) throws IOException {
    jgen.writeStartObject();

    writeVersieRegel(jgen, value.getMainVersion());

    jgen.writeArrayFieldStart(VersieModule.COMPONENTEN);
    for (final VersionLine component : value.getComponentVersions()) {
        jgen.writeStartObject();
        writeVersieRegel(jgen, component);
        jgen.writeEndObject();
    }
    jgen.writeEndArray();

    jgen.writeEndObject();
}
 
開發者ID:MinBZK,項目名稱:OperatieBRP,代碼行數:17,代碼來源:VersionSerializer.java

示例13: serialize

import com.fasterxml.jackson.core.JsonGenerator; //導入依賴的package包/類
@Override
public void serialize(JsonGenerator generator) throws IOException {
	generator.writeNumber(getCode());
	generator.writeNumber(this.requestId);
	generator.writeStartObject();
	generator.writeEndObject();

	if (this.argumentsKw != null) {
		if (this.arguments == null) {
			generator.writeStartArray();
			generator.writeEndArray();
		}
		else {
			generator.writeObject(this.arguments);
		}
		generator.writeObject(this.argumentsKw);
	}
	else if (this.arguments != null) {
		generator.writeObject(this.arguments);
	}
}
 
開發者ID:ralscha,項目名稱:wamp2spring,代碼行數:22,代碼來源:YieldMessage.java

示例14: 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

示例15: serialize

import com.fasterxml.jackson.core.JsonGenerator; //導入依賴的package包/類
@Override
    public void serialize(Wrapper<?> value, JsonGenerator gen, SerializerProvider provider) throws IOException {
        // TODO: maybe find a cleaner way to do this
        if(Vector.class.isAssignableFrom(value.getWrappedClass())) {
            // value is a vector, just write the coordinates
            gen.writeObject(((Vector) value.getWrapped()).toArray());
            return;
        }
        gen.writeStartObject();
        gen.writeStringField("class", value.getWrappedClass().getSimpleName());
        gen.writeNumberField("id", value.getWrappedId());
        value.getValues().forEach((name, obj) -> {
            try {
                gen.writeObjectField(name, obj);
            } catch (IOException e) {
                e.printStackTrace();
            }
        });
//        for(Property p : value.getProperties()) {
//            gen.writeObjectField(p.getName(), p);
//        }
        gen.writeEndObject();
    }
 
開發者ID:etomica,項目名稱:etomica,代碼行數:24,代碼來源:WrapperSerializer.java


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