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