本文整理汇总了Java中com.fasterxml.jackson.databind.SerializerProvider.findValueSerializer方法的典型用法代码示例。如果您正苦于以下问题:Java SerializerProvider.findValueSerializer方法的具体用法?Java SerializerProvider.findValueSerializer怎么用?Java SerializerProvider.findValueSerializer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.fasterxml.jackson.databind.SerializerProvider
的用法示例。
在下文中一共展示了SerializerProvider.findValueSerializer方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: serializeFields
import com.fasterxml.jackson.databind.SerializerProvider; //导入方法依赖的package包/类
@Override
protected void serializeFields(Object bean, final JsonGenerator gen, SerializerProvider provider) throws IOException {
if (bean instanceof ExtendedJsonWrapper) {
ExtendedJsonWrapper mixin = (ExtendedJsonWrapper) bean;
Object origin = mixin.getOrigin();
BeanSerializer serializer = (BeanSerializer) provider.findValueSerializer(origin.getClass());
new ExtendedJsonSerializer(serializer).serializeFieldsFiltered(origin, gen, provider);
Set<Entry<String, Object>> entries = mixin.getMixed().entrySet();
//gen.writeObjectField("mixedIn", mixin.getMixed());
for (Entry<String, Object> entry : entries) {
if(entry.getValue() != null){
try {
gen.writeObjectField(entry.getKey(), entry.getValue());
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}
} else {
super.serializeFields(bean, gen, provider);
}
}
示例2: serialize
import com.fasterxml.jackson.databind.SerializerProvider; //导入方法依赖的package包/类
@Override
public void serialize(
Resources value, JsonGenerator jgen, SerializerProvider provider)
throws IOException, JsonProcessingException
{
// Extracted the actual data inside of the Resources object that we care about
Object content = value.getContent();
// Instead of all of the Resources member variables, etc.
// Just mashall the actual content into the JSON
JsonSerializer<Object> s = provider.findValueSerializer(content.getClass(), null);
s.serialize(content, jgen, provider);
}