本文整理汇总了Java中com.fasterxml.jackson.databind.SerializerProvider.defaultSerializeNull方法的典型用法代码示例。如果您正苦于以下问题:Java SerializerProvider.defaultSerializeNull方法的具体用法?Java SerializerProvider.defaultSerializeNull怎么用?Java SerializerProvider.defaultSerializeNull使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.fasterxml.jackson.databind.SerializerProvider
的用法示例。
在下文中一共展示了SerializerProvider.defaultSerializeNull方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
示例2: serializeContents
import com.fasterxml.jackson.databind.SerializerProvider; //导入方法依赖的package包/类
protected void serializeContents(Collection<?> value, JsonGenerator gen, SerializerProvider provider)
throws IOException {
int i = 0;
try {
for (Object elem : value) {
if (elem != null) {
serializeWithMask((String) elem, gen, provider);
} else {
provider.defaultSerializeNull(gen);
}
++i;
}
} catch (Exception e) {
wrapAndThrow(provider, e, value, i);
}
}
示例3: serialize
import com.fasterxml.jackson.databind.SerializerProvider; //导入方法依赖的package包/类
@Override
public void serialize(HibernateProxy value, JsonGenerator jgen,
SerializerProvider provider) throws IOException,
JsonProcessingException {
Object proxiedValue = findProxied(value);
// TODO: figure out how to suppress nulls, if necessary? (too late for
// that here)
if (proxiedValue == null) {
provider.defaultSerializeNull(jgen);
return;
}
findSerializer(provider, proxiedValue).serialize(proxiedValue, jgen,
provider);
}
示例4: serialize
import com.fasterxml.jackson.databind.SerializerProvider; //导入方法依赖的package包/类
@Override
public void serialize(Point value, JsonGenerator jgen, SerializerProvider provider) throws IOException {
if (value == null || value.getCoordinate() == null) {
provider.defaultSerializeNull(jgen);
} else {
jgen.writeStartObject();
jgen.writeObjectField("x", value.getX());
jgen.writeObjectField("y", value.getY());
jgen.writeEndObject();
}
}