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


Java SerializerProvider类代码示例

本文整理汇总了Java中com.fasterxml.jackson.databind.SerializerProvider的典型用法代码示例。如果您正苦于以下问题:Java SerializerProvider类的具体用法?Java SerializerProvider怎么用?Java SerializerProvider使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: configProtobufSerializer

import com.fasterxml.jackson.databind.SerializerProvider; //导入依赖的package包/类
@Bean
public Jackson2ObjectMapperBuilderCustomizer configProtobufSerializer() {
	return new Jackson2ObjectMapperBuilderCustomizer() {

		@Override
		public void customize(
				Jackson2ObjectMapperBuilder builder) {
			builder.serializerByType(Message.class, new JsonSerializer<Message>(){

				@Override
				public void serialize(Message message, JsonGenerator generator,
						SerializerProvider provider) throws IOException {
					if(message == null)
						return;
					JsonJacksonFormat format = new JsonJacksonFormat();
					format.print(message, generator);
				}});
			
		}
	};
}
 
开发者ID:jigsaw-projects,项目名称:jigsaw-payment,代码行数:22,代码来源:ProtobufConfiguration.java

示例2: serialize

import com.fasterxml.jackson.databind.SerializerProvider; //导入依赖的package包/类
@Override
public void serialize(JsonHistogram jsonHistogram,
                      JsonGenerator json,
                      SerializerProvider provider) throws IOException {
    json.writeStartObject();
    json.writeStringField("name", jsonHistogram.name());
    json.writeObjectField(timestampFieldname, jsonHistogram.timestampAsDate());
    Histogram histogram = jsonHistogram.value();

    final Snapshot snapshot = histogram.getSnapshot();
    json.writeNumberField("count", histogram.getCount());
    json.writeNumberField("max", snapshot.getMax());
    json.writeNumberField("mean", snapshot.getMean());
    json.writeNumberField("min", snapshot.getMin());
    json.writeNumberField("p50", snapshot.getMedian());
    json.writeNumberField("p75", snapshot.get75thPercentile());
    json.writeNumberField("p95", snapshot.get95thPercentile());
    json.writeNumberField("p98", snapshot.get98thPercentile());
    json.writeNumberField("p99", snapshot.get99thPercentile());
    json.writeNumberField("p999", snapshot.get999thPercentile());

    json.writeNumberField("stddev", snapshot.getStdDev());
    addOneOpsMetadata(json);
    json.writeEndObject();
}
 
开发者ID:oneops,项目名称:oneops,代码行数:26,代码来源:MetricsElasticsearchModule.java

示例3: serialize

import com.fasterxml.jackson.databind.SerializerProvider; //导入依赖的package包/类
@Override
public void serialize(Area area, JsonGenerator jgen, SerializerProvider sp)
    throws IOException, JsonProcessingException {

  jgen.writeStartObject();

  super.serialize(area, jgen, sp);

  if (area.getColor() instanceof Color) {
    jgen.writeObjectField("color", area.getColor());
  }
  if (area.getInterpolation() != null) {
    jgen.writeObjectField("interpolation", area.getInterpolation());
  }
  jgen.writeEndObject();
}
 
开发者ID:twosigma,项目名称:beaker-notebook-archive,代码行数:17,代码来源:AreaSerializer.java

示例4: serialize

import com.fasterxml.jackson.databind.SerializerProvider; //导入依赖的package包/类
/**
 * Perform custom JSON serialization
 * 
 * @param leg                      the bet leg to be serialized
 * @param jgen                     needed to conform to Jackson interface
 * @param sp                       needed to conform to Jackson interface
 * @throws IOException             if any fields could not be written
 * @throws JsonProcessingException if the JSON could not be produced
 */
@Override
public void serialize(final Leg leg, final JsonGenerator jgen, final SerializerProvider sp) throws IOException, JsonProcessingException {
    jgen.writeStartObject();
    jgen.writeNumberField("race", leg.getRace().getID());
    jgen.writeNumberField("backing", leg.getBacking().getID());
    jgen.writeNumberField("oddsVersion", leg.getOddsVersion());
    final OddsType ot = leg.getoType();
    jgen.writeStringField("oddsType", "" + ot);
    if (ot == OddsType.FIXED_ODDS) {
        jgen.writeNumberField("odds", leg.odds());
    }
    if (leg.hasStake()) {
        jgen.writeNumberField("stake", leg.stake());
    }
    jgen.writeEndObject();
}
 
开发者ID:hazelcast,项目名称:betleopard,代码行数:26,代码来源:CustomLegSerializer.java

示例5: serializeWithType

import com.fasterxml.jackson.databind.SerializerProvider; //导入依赖的package包/类
@Override
public void serializeWithType(HibernateProxy value, JsonGenerator jgen,
		SerializerProvider provider, TypeSerializer typeSer)
		throws IOException, JsonProcessingException {
	Object proxiedValue = findProxied(value);
	if (proxiedValue == null) {
		provider.defaultSerializeNull(jgen);
		return;
	}
	/*
	 * This isn't exactly right, since type serializer really refers to
	 * proxy object, not value. And we really don't either know static type
	 * (necessary to know how to apply additional type info) or other
	 * things; so it's not going to work well. But... we'll do out best.
	 */
	findSerializer(provider, proxiedValue).serializeWithType(proxiedValue,
			jgen, provider, typeSer);
}
 
开发者ID:jmfgdev,项目名称:gitplex-mit,代码行数:19,代码来源:HibernateProxySerializer.java

示例6: serialize

import com.fasterxml.jackson.databind.SerializerProvider; //导入依赖的package包/类
@Override
public final void serialize(final DienstbundelLo3RubriekView value, final JsonGenerator jgen, final SerializerProvider provider) throws IOException {
    jgen.writeStartObject();
    JsonUtils.writeAsInteger(jgen, DienstbundelLo3RubriekModule.ID, value.getId());

    JsonUtils.writeAsString(
        jgen,
        DienstbundelLo3RubriekModule.ACTIEF,
        value.isActief(),
        DienstbundelLo3RubriekModule.WAARDE_JA,
        DienstbundelLo3RubriekModule.WAARDE_NEE);

    JsonUtils.writeAsInteger(jgen, DienstbundelLo3RubriekModule.DIENSTBUNDEL, value.getDienstbundel().getId());

    JsonUtils.writeAsInteger(jgen, DienstbundelLo3RubriekModule.RUBRIEK, value.getLo3Rubriek().getId());
    JsonUtils.writeAsString(jgen, DienstbundelLo3RubriekModule.RUBRIEK_NAAM, value.getLo3Rubriek().getNaam());

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

示例7: serialize

import com.fasterxml.jackson.databind.SerializerProvider; //导入依赖的package包/类
/**
  * Performs the serialization of a OneComponentTime object
  */
@Override
public void serialize(CumulativeTimeBucket ctb,
                JsonGenerator jGen,
                SerializerProvider serializer) 
                throws IOException, JsonProcessingException {
    jGen.writeStartObject();
    Timestamp ts = new Timestamp(ctb.getStartTimeNs()/1000000);
    jGen.writeStringField("start-time", ts.toString());
    jGen.writeStringField("current-time", 
      new Timestamp(System.currentTimeMillis()).toString());
    jGen.writeNumberField("total-packets", ctb.getTotalPktCnt());
    jGen.writeNumberField("average", ctb.getAverageProcTimeNs());
    jGen.writeNumberField("min", ctb.getMinTotalProcTimeNs());
    jGen.writeNumberField("max", ctb.getMaxTotalProcTimeNs());
    jGen.writeNumberField("std-dev", ctb.getTotalSigmaProcTimeNs());
    jGen.writeArrayFieldStart("modules");
    for (OneComponentTime oct : ctb.getModules()) {
        serializer.defaultSerializeValue(oct, jGen);
    }
    jGen.writeEndArray();
    jGen.writeEndObject();
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:26,代码来源:CumulativeTimeBucketJSONSerializer.java

示例8: serialize

import com.fasterxml.jackson.databind.SerializerProvider; //导入依赖的package包/类
@Override
public final void serialize(final AdministratieveHandeling value, final JsonGenerator jgen, final SerializerProvider provider) throws IOException {
    jgen.writeStartObject();
    JsonUtils.writeAsInteger(jgen, "id", value.getId());
    JsonUtils.writeAsInteger(jgen, Element.ADMINISTRATIEVEHANDELING_SOORTNAAM.getElementNaam(), ObjectUtils.<Integer>getWaarde(value, "soort.id"));
    JsonUtils.writeAsInteger(jgen, Element.ADMINISTRATIEVEHANDELING_PARTIJCODE.getElementNaam(), ObjectUtils.<Short>getWaarde(value, "partij.id"));
    JsonUtils.writeAsString(
        jgen,
        Element.ADMINISTRATIEVEHANDELING_PARTIJCODE.getElementNaam() + Element.PARTIJ_CODE.getElementNaam(),
        ObjectUtils.getWaarde(value, "partij.code"));
    JsonUtils.writeAsString(
        jgen,
        Element.ADMINISTRATIEVEHANDELING_TIJDSTIPREGISTRATIE.getElementNaam(),
        ObjectUtils.getGeformateerdeWaarde(value, "datumTijdRegistratie", sdf));
    JsonUtils.writeAsString(
        jgen,
        Element.ADMINISTRATIEVEHANDELING_LEVERING_TIJDSTIP.getElementNaam(),
        ObjectUtils.getGeformateerdeWaarde(value, "datumTijdLevering", sdf));
    JsonUtils.writeAsString(
        jgen,
        Element.ADMINISTRATIEVEHANDELING_TOELICHTINGONTLENING.getElementNaam(),
        ObjectUtils.<String>getWaarde(value, "toelichtingOntlening"));
    jgen.writeEndObject();
}
 
开发者ID:MinBZK,项目名称:OperatieBRP,代码行数:25,代码来源:AdministratieveHandelingSerializer.java

示例9: serialize

import com.fasterxml.jackson.databind.SerializerProvider; //导入依赖的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

示例10: serialize

import com.fasterxml.jackson.databind.SerializerProvider; //导入依赖的package包/类
@Override
public void serialize(Face value, JsonGenerator jgen, SerializerProvider provider)
		throws IOException {
	jgen.writeStartObject();
	jgen.writeFieldId(1);
	jgen.writeObject(value.sai);
	jgen.writeFieldId(5);
	jgen.writeNumber(value.getTs().getTime()/1000);
	jgen.writeFieldId(6);
	jgen.writeNumber(value.getLifetime());
	jgen.writeFieldId(12);
	jgen.writeBinary(value.getNonce());
	jgen.writeFieldId(7);
	jgen.writeNumber(value.macMethod.encoding);
	jgen.writeEndObject();
}
 
开发者ID:beduino-project,项目名称:dcaf-java,代码行数:17,代码来源:Face.java

示例11: serialize

import com.fasterxml.jackson.databind.SerializerProvider; //导入依赖的package包/类
@Override
public void serialize(XYChart xychart, JsonGenerator jgen, SerializerProvider sp)
  throws IOException, JsonProcessingException {

  jgen.writeStartObject();

  serialize(xychart, jgen);

  jgen.writeObjectField(GRAPHICS_LIST, xychart.getGraphics());
  jgen.writeObjectField("constant_lines", xychart.getConstantLines());
  jgen.writeObjectField("constant_bands", xychart.getConstantBands());
  jgen.writeObjectField("rasters", xychart.getRasters());
  jgen.writeObjectField("texts", xychart.getTexts());
  jgen.writeObjectField("x_auto_range", xychart.getXAutoRange());
  jgen.writeObjectField("x_lower_bound", xychart.getXLowerBound());
  jgen.writeObjectField("x_upper_bound", xychart.getXUpperBound());
  jgen.writeObjectField("log_x", xychart.getLogX());
  jgen.writeObjectField("x_log_base", xychart.getXLogBase());
  if (xychart.getLodThreshold() != null) {
    jgen.writeObjectField(LOD_THRESHOLD, xychart.getLodThreshold());
  }
  jgen.writeObjectField("x_tickLabels_visible", xychart.isxTickLabelsVisible());
  jgen.writeObjectField("y_tickLabels_visible", xychart.isyTickLabelsVisible());
  jgen.writeEndObject();
}
 
开发者ID:twosigma,项目名称:beaker-notebook-archive,代码行数:26,代码来源:XYChartSerializer.java

示例12: serialize

import com.fasterxml.jackson.databind.SerializerProvider; //导入依赖的package包/类
@Override
public void serialize(BeakerCodeCell value,
    JsonGenerator jgen,
    SerializerProvider provider)
    throws IOException, JsonProcessingException {

  synchronized (value) {
    jgen.writeStartObject();
    jgen.writeStringField("type", "BeakerCodeCell");
    jgen.writeStringField("execution_count", value.executionCount);
    jgen.writeStringField("cell_type", value.cellType);
    jgen.writeFieldName("outputs");
    if (!getObjectSerializer().writeObject(value.outputs, jgen, true))
      jgen.writeString(value.outputs.toString());
    jgen.writeFieldName("metadata");
    if (!getObjectSerializer().writeObject(value.metadata, jgen, true))
      jgen.writeString(value.metadata.toString());
    jgen.writeStringField("source", value.source);
    jgen.writeEndObject();
  }
}
 
开发者ID:twosigma,项目名称:beaker-notebook-archive,代码行数:22,代码来源:BeakerCodeCell.java

示例13: serialize

import com.fasterxml.jackson.databind.SerializerProvider; //导入依赖的package包/类
@Override
public void serialize(Crosshair crosshair, JsonGenerator jgen, SerializerProvider sp)
    throws IOException, JsonProcessingException {

  jgen.writeStartObject();
  jgen.writeObjectField("type", crosshair.getClass().getSimpleName());
  if (crosshair.getColor() instanceof Color) {
    jgen.writeObjectField("color", crosshair.getColor());
  }
  if (crosshair.getStyle() != null) {
    jgen.writeObjectField("style", crosshair.getStyle().toString());
  }
  if (crosshair.getWidth() != null) {
    jgen.writeObjectField("width", crosshair.getWidth());
  }
  jgen.writeEndObject();
}
 
开发者ID:twosigma,项目名称:beaker-notebook-archive,代码行数:18,代码来源:CrosshairSerializer.java

示例14: serialize

import com.fasterxml.jackson.databind.SerializerProvider; //导入依赖的package包/类
@Override
public void serialize(Enum value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
    if (value == null) {
        gen.writeNull();
        return;
    }
    try {
        PropertyDescriptor pd = getPropertyDescriptor(value, prop);
        if (pd == null || pd.getReadMethod() == null) {
            gen.writeString(value.name());
            return;
        }
        Method m = pd.getReadMethod();
        m.setAccessible(true);
        gen.writeObject(m.invoke(value));
    } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:thlcly,项目名称:Dude,代码行数:20,代码来源:CustomEnumSerializer.java

示例15: serialize

import com.fasterxml.jackson.databind.SerializerProvider; //导入依赖的package包/类
@Override
public final void serialize(final DienstbundelGroepAttribuutView value, final JsonGenerator jgen, final SerializerProvider provider)
        throws IOException {
    jgen.writeStartObject();
    JsonUtils.writeAsInteger(jgen, DienstbundelGroepAttribuutModule.ID, value.getId());
    JsonUtils.writeAsInteger(jgen, DienstbundelGroepAttribuutModule.DIENSTBUNDEL_GROEP, value.getDienstbundelGroep().getId());
    JsonUtils.writeAsString(
            jgen,
            DienstbundelGroepAttribuutModule.ACTIEF,
            value.isActief(),
            DienstbundelGroepAttribuutModule.WAARDE_JA,
            DienstbundelGroepAttribuutModule.WAARDE_NEE);
    JsonUtils.writeAsString(jgen, DienstbundelGroepAttribuutModule.ATTRIBUUT_NAAM, value.getAttribuut().getNaam());
    JsonUtils.writeAsInteger(jgen, DienstbundelGroepAttribuutModule.ATTRIBUUT, value.getAttribuut().getId());
    JsonUtils.writeAsInteger(jgen, DienstbundelGroepAttribuutModule.SOORT, EnumUtils.getId(value.getAttribuut().getSoortAutorisatie()));
    jgen.writeEndObject();
}
 
开发者ID:MinBZK,项目名称:OperatieBRP,代码行数:18,代码来源:DienstbundelGroepAttribuutSerializer.java


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