本文整理汇总了Java中com.fasterxml.jackson.databind.ser.BeanSerializer类的典型用法代码示例。如果您正苦于以下问题:Java BeanSerializer类的具体用法?Java BeanSerializer怎么用?Java BeanSerializer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BeanSerializer类属于com.fasterxml.jackson.databind.ser包,在下文中一共展示了BeanSerializer类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: serializeFields
import com.fasterxml.jackson.databind.ser.BeanSerializer; //导入依赖的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);
}
}
开发者ID:savantly-net,项目名称:log4j2-extended-jsonlayout,代码行数:29,代码来源:ExtendedJsonSerializer.java
示例2: findSerializer
import com.fasterxml.jackson.databind.ser.BeanSerializer; //导入依赖的package包/类
private JsonSerializer<Object> findSerializer(Class<?> type, SerializerProvider provider, boolean eventBean)
throws JsonMappingException
{
JsonSerializer<Object> serializer = serializers.serializerFor(type);
if (serializer != null)
return serializer;
serializer = provider.findValueSerializer(type, null);
if (eventBean)
serializer = new EventBeanSerializer((BeanSerializer)serializer);
serializers = serializers.newWith(type, serializer);
return serializer;
}
开发者ID:Devexperts,项目名称:QD,代码行数:13,代码来源:DataMessageSerializer.java
示例3: modifySerializer
import com.fasterxml.jackson.databind.ser.BeanSerializer; //导入依赖的package包/类
@Override
public JsonSerializer<?> modifySerializer(SerializationConfig config, BeanDescription beanDesc,
JsonSerializer<?> serializer) {
if (serializer instanceof BeanSerializer) {
return new BeanSerializerWrapper((BeanSerializer) serializer);
} else {
return serializer;
}
}
开发者ID:openwide-java,项目名称:owsi-core-parent,代码行数:10,代码来源:HibernateBeanSerializerModifier.java
示例4: EventBeanSerializer
import com.fasterxml.jackson.databind.ser.BeanSerializer; //导入依赖的package包/类
EventBeanSerializer(BeanSerializer src) {
super(src);
}
开发者ID:Devexperts,项目名称:QD,代码行数:4,代码来源:EventBeanSerializer.java
示例5: BeanSerializerWrapper
import com.fasterxml.jackson.databind.ser.BeanSerializer; //导入依赖的package包/类
protected BeanSerializerWrapper(BeanSerializer src) {
super(src);
this.serializer = src;
}
开发者ID:openwide-java,项目名称:owsi-core-parent,代码行数:5,代码来源:HibernateBeanSerializerModifier.java
示例6: ExtensibleObjectSerializer
import com.fasterxml.jackson.databind.ser.BeanSerializer; //导入依赖的package包/类
public ExtensibleObjectSerializer(BeanSerializer src) {
super(src);
}
开发者ID:FamilySearch,项目名称:gedcomx-java,代码行数:4,代码来源:ExtensibleObjectSerializer.java
示例7: modifySerializer
import com.fasterxml.jackson.databind.ser.BeanSerializer; //导入依赖的package包/类
@Override
public JsonSerializer<?> modifySerializer(SerializationConfig config, BeanDescription beanDesc, JsonSerializer<?> serializer) {
return (serializer instanceof BeanSerializer) ? new ExtensibleObjectSerializer((BeanSerializer) serializer) : serializer;
}
开发者ID:FamilySearch,项目名称:gedcomx-java,代码行数:5,代码来源:GedcomBeanSerializerModifier.java
示例8: DefaultJsonService
import com.fasterxml.jackson.databind.ser.BeanSerializer; //导入依赖的package包/类
/**
* Constructs and initializes a JsonService with an {@link ObjectService}.
*
* @param objectService
*/
public DefaultJsonService(final ObjectService objectService) {
idToObjDeserializer = new UntypedObjectDeserializer(null, null) {
@Override
public Object deserialize(JsonParser p, DeserializationContext ctxt)
throws IOException, JsonProcessingException
{
final Object obj = super.deserialize(p, ctxt);
if (!(obj instanceof String && ((String) obj).startsWith("object:")))
return obj;
final String id = (String) obj;
if (!objectService.contains(id)) {
throw new JsonMappingException(p, "Object does not exist");
}
final ObjectInfo info = objectService.find(id);
info.updateLastUsed();
return info.getObject();
}
};
final JsonSerializer<Object> objToIdSerializer =
new JsonSerializer<Object>()
{
@Override
public void serialize(Object value, JsonGenerator gen,
SerializerProvider serializers) throws IOException,
JsonProcessingException
{
gen.writeString(objectService.register(value, "DefaultJsonService"));
}
};
final SimpleModule objToIdModule = new SimpleModule();
objToIdModule.setSerializerModifier(new BeanSerializerModifier() {
@Override
public JsonSerializer<?> modifySerializer(SerializationConfig config,
BeanDescription beanDesc, JsonSerializer<?> serializer)
{
if (Mixins.support(beanDesc.getBeanClass())) return serializer;
// If the serialized class is unknown (i.e. serialized using the general
// BeanSerializer) or should not be serialized (i.e. complicated class
// implemented interfaces such as Iterable), would be serialized as an
// ID.
if (serializer instanceof BeanSerializer) return objToIdSerializer;
if (notSerialized(beanDesc.getBeanClass())) return objToIdSerializer;
return serializer;
}
});
objToIdMapper = new ObjectMapper();
objToIdMapper.registerModule(objToIdModule);
// register Jackson MixIns to obtain better json output format for some
// specific types
Mixins.registerMixIns(objToIdMapper);
}
开发者ID:imagej,项目名称:imagej-server,代码行数:66,代码来源:DefaultJsonService.java
注:本文中的com.fasterxml.jackson.databind.ser.BeanSerializer类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论