本文整理汇总了Java中com.fasterxml.jackson.databind.jsontype.TypeSerializer类的典型用法代码示例。如果您正苦于以下问题:Java TypeSerializer类的具体用法?Java TypeSerializer怎么用?Java TypeSerializer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TypeSerializer类属于com.fasterxml.jackson.databind.jsontype包,在下文中一共展示了TypeSerializer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: serializeWithType
import com.fasterxml.jackson.databind.jsontype.TypeSerializer; //导入依赖的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);
}
示例2: serializeWithType
import com.fasterxml.jackson.databind.jsontype.TypeSerializer; //导入依赖的package包/类
@Override
public void serializeWithType(LocalDateTime value, JsonGenerator g, SerializerProvider provider,
TypeSerializer typeSer) throws IOException
{
WritableTypeId typeIdDef = typeSer.writeTypePrefix(g,
typeSer.typeId(value, serializationShape(provider)));
// need to write out to avoid double-writing array markers
if (typeIdDef.valueShape == JsonToken.START_ARRAY) {
_serializeAsArrayContents(value, g, provider);
} else {
DateTimeFormatter dtf = _formatter;
if (dtf == null) {
dtf = _defaultFormatter();
}
g.writeString(value.format(dtf));
}
typeSer.writeTypeSuffix(g, typeIdDef);
}
示例3: serializeWithType
import com.fasterxml.jackson.databind.jsontype.TypeSerializer; //导入依赖的package包/类
@Override
public void serializeWithType(final X509CertificateCredential value, final JsonGenerator generator,
final SerializerProvider serializers, final TypeSerializer typeSer) throws IOException {
try {
typeSer.writeTypePrefixForObject(value, generator);
serialize(value, generator, serializers);
typeSer.writeTypeSuffixForObject(value, generator);
} catch (final Exception e) {
throw new JsonMappingException("Unable to serialize X509 certificate", e);
}
}
示例4: serializeWithType
import com.fasterxml.jackson.databind.jsontype.TypeSerializer; //导入依赖的package包/类
@Override
public void serializeWithType(JoinFunction value, JsonGenerator gen, SerializerProvider serializers,
TypeSerializer typeSer) throws IOException {
typeSer.writeTypePrefixForScalar(value, gen);
serialize(value, gen, serializers);
typeSer.writeTypeSuffixForScalar(value, gen);
}
示例5: serializeWithType
import com.fasterxml.jackson.databind.jsontype.TypeSerializer; //导入依赖的package包/类
@Override
public void serializeWithType(SelectFunction value, JsonGenerator gen, SerializerProvider serializers,
TypeSerializer typeSer) throws IOException {
typeSer.writeTypePrefixForScalar(value, gen);
serialize(value, gen, serializers);
typeSer.writeTypeSuffixForScalar(value, gen);
}
示例6: serializeWithType
import com.fasterxml.jackson.databind.jsontype.TypeSerializer; //导入依赖的package包/类
@Override
public void serializeWithType(StringValue value, JsonGenerator gen, SerializerProvider serializers,
TypeSerializer typeSer) throws IOException {
typeSer.writeTypePrefixForScalar(value, gen);
serialize(value, gen, serializers);
typeSer.writeTypeSuffixForScalar(value, gen);
}
示例7: serializeWithType
import com.fasterxml.jackson.databind.jsontype.TypeSerializer; //导入依赖的package包/类
@Override
public void serializeWithType(
com.salesforce.cf2pojo.model.RefValue value, JsonGenerator gen, SerializerProvider serializers,
TypeSerializer typeSer) throws IOException {
typeSer.writeTypePrefixForScalar(value, gen);
serialize(value, gen, serializers);
typeSer.writeTypeSuffixForScalar(value, gen);
}
示例8: serializeWithType
import com.fasterxml.jackson.databind.jsontype.TypeSerializer; //导入依赖的package包/类
@Override
public void serializeWithType(com.salesforce.cf2pojo.model.GetAttFunction value, JsonGenerator gen,
SerializerProvider serializers, TypeSerializer typeSer) throws IOException {
typeSer.writeTypePrefixForScalar(value, gen);
serialize(value, gen, serializers);
typeSer.writeTypeSuffixForScalar(value, gen);
}
示例9: serializeWithType
import com.fasterxml.jackson.databind.jsontype.TypeSerializer; //导入依赖的package包/类
@Override
public void serializeWithType(Base64Function value, JsonGenerator gen, SerializerProvider serializers,
TypeSerializer typeSer) throws IOException {
typeSer.writeTypePrefixForScalar(value, gen);
serialize(value, gen, serializers);
typeSer.writeTypeSuffixForScalar(value, gen);
}
示例10: serializeWithType
import com.fasterxml.jackson.databind.jsontype.TypeSerializer; //导入依赖的package包/类
@Override
public void serializeWithType(SubFunction value, JsonGenerator gen, SerializerProvider serializers,
TypeSerializer typeSer) throws IOException {
typeSer.writeTypePrefixForScalar(value, gen);
serialize(value, gen, serializers);
typeSer.writeTypeSuffixForScalar(value, gen);
}
示例11: serializeWithType
import com.fasterxml.jackson.databind.jsontype.TypeSerializer; //导入依赖的package包/类
@Override
public void serializeWithType(FindInMapFunction value, JsonGenerator gen, SerializerProvider serializers,
TypeSerializer typeSer) throws IOException {
typeSer.writeTypePrefixForScalar(value, gen);
serialize(value, gen, serializers);
typeSer.writeTypeSuffixForScalar(value, gen);
}
示例12: serializeWithType
import com.fasterxml.jackson.databind.jsontype.TypeSerializer; //导入依赖的package包/类
@Override
public void serializeWithType(IfFunction value, JsonGenerator gen, SerializerProvider serializers,
TypeSerializer typeSer) throws IOException {
typeSer.writeTypePrefixForScalar(value, gen);
serialize(value, gen, serializers);
typeSer.writeTypeSuffixForScalar(value, gen);
}
示例13: serializeWithType
import com.fasterxml.jackson.databind.jsontype.TypeSerializer; //导入依赖的package包/类
@Override
public void serializeWithType(BigDecimal value, JsonGenerator gen, SerializerProvider provider,
TypeSerializer typeSer) throws IOException {
typeSer.writeTypePrefixForScalar(value, gen);
serialize(value, gen, provider);
typeSer.writeTypeSuffixForScalar(value, gen);
}
示例14: serializeFieldTyped
import com.fasterxml.jackson.databind.jsontype.TypeSerializer; //导入依赖的package包/类
protected void serializeFieldTyped(
Entity entity,
JsonGenerator gen,
SerializerProvider serializers,
BeanDescription beanDescription,
BeanPropertyDefinition beanPropertyDefinition,
TypeSerializer typeSerializer) throws Exception {
try {
if (typeSerializer == null) {
typeSerializer = serializers.findTypeSerializer(serializers.constructType(beanPropertyDefinition.getAccessor().getRawType()));
}
if (typeSerializer == null) {
// if not static type if available use dynamic type if available
Object propertyValue = beanPropertyDefinition.getAccessor().getValue(entity);
if (propertyValue != null) {
typeSerializer = serializers.findTypeSerializer(serializers.constructType(propertyValue.getClass()));
}
}
BeanPropertyWriter bpw = new BeanPropertyWriter(
beanPropertyDefinition,
beanPropertyDefinition.getAccessor(),
beanDescription.getClassAnnotations(),
beanPropertyDefinition.getAccessor().getType(),
null, // will be searched automatically
typeSerializer, // will not be searched automatically
beanPropertyDefinition.getAccessor().getType(),
suppressNulls(serializers.getConfig().getDefaultPropertyInclusion()),
suppressableValue(serializers.getConfig().getDefaultPropertyInclusion()));
bpw.serializeAsField(entity, gen, serializers);
} catch (JsonMappingException ex) {
Logger.getLogger(EntitySerializer.class.getName()).log(Level.SEVERE, null, ex);
}
}
示例15: serializeWithType
import com.fasterxml.jackson.databind.jsontype.TypeSerializer; //导入依赖的package包/类
@Override
public void serializeWithType( final ContainerResource value, final JsonGenerator gen,
final SerializerProvider serializers, final TypeSerializer typeSer )
throws IOException
{
typeSer.writeTypePrefixForObject( value, gen );
serialize( value, gen, serializers );
typeSer.writeTypeSuffixForObject( value, gen );
}