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