本文整理汇总了Java中com.fasterxml.jackson.databind.ser.std.NullSerializer类的典型用法代码示例。如果您正苦于以下问题:Java NullSerializer类的具体用法?Java NullSerializer怎么用?Java NullSerializer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NullSerializer类属于com.fasterxml.jackson.databind.ser.std包,在下文中一共展示了NullSerializer类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getValueSerializer
import com.fasterxml.jackson.databind.ser.std.NullSerializer; //导入依赖的package包/类
private SchemaAware getValueSerializer(Object valueAsJavaType) throws JsonMappingException {
SerializerProvider serializerProvider = new DefaultSerializerProvider.Impl().createInstance(OBJECT_MAPPER.getSerializationConfig(), BeanSerializerFactory.instance);
if (valueAsJavaType == null) {
return NullSerializer.instance;
} else {
Class<? extends Object> javaTypeForValue = valueAsJavaType.getClass();
JsonSerializer<Object> valueSerializer = serializerProvider.findValueSerializer(javaTypeForValue, null);
return (SchemaAware) valueSerializer;
}
}
示例2: CustomObjectMapper
import com.fasterxml.jackson.databind.ser.std.NullSerializer; //导入依赖的package包/类
public CustomObjectMapper() {
DefaultSerializerProvider sp = new DefaultSerializerProvider.Impl();
sp.setNullValueSerializer(NullSerializer.instance);
this.setSerializerProvider(sp);
}
示例3: getNullSerializer
import com.fasterxml.jackson.databind.ser.std.NullSerializer; //导入依赖的package包/类
public final JsonSerializer<?> getNullSerializer()
{
return NullSerializer.instance;
}