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