use of com.fasterxml.jackson.databind.ser.FilterProvider in project redisson by redisson.
the class ConfigSupport method createMapper.
private ObjectMapper createMapper(JsonFactory mapping, ClassLoader classLoader) {
ObjectMapper mapper = new ObjectMapper(mapping);
mapper.addMixIn(MasterSlaveServersConfig.class, MasterSlaveServersConfigMixIn.class);
mapper.addMixIn(SingleServerConfig.class, SingleSeverConfigMixIn.class);
mapper.addMixIn(Config.class, ConfigMixIn.class);
mapper.addMixIn(CodecProvider.class, ClassMixIn.class);
mapper.addMixIn(ResolverProvider.class, ClassMixIn.class);
mapper.addMixIn(Codec.class, ClassMixIn.class);
mapper.addMixIn(RedissonNodeInitializer.class, ClassMixIn.class);
mapper.addMixIn(LoadBalancer.class, ClassMixIn.class);
FilterProvider filterProvider = new SimpleFilterProvider().addFilter("classFilter", SimpleBeanPropertyFilter.filterOutAllExcept());
mapper.setFilterProvider(filterProvider);
mapper.setSerializationInclusion(Include.NON_NULL);
if (classLoader != null) {
TypeFactory tf = TypeFactory.defaultInstance().withClassLoader(classLoader);
mapper.setTypeFactory(tf);
}
return mapper;
}
use of com.fasterxml.jackson.databind.ser.FilterProvider in project jackson-module-afterburner by FasterXML.
the class TestJsonFilter method testFilterOnProperty.
// Wrt [Issue#306]
public void testFilterOnProperty() throws Exception {
FilterProvider prov = new SimpleFilterProvider().addFilter("RootFilter", SimpleBeanPropertyFilter.filterOutAllExcept("a")).addFilter("b", SimpleBeanPropertyFilter.filterOutAllExcept("b"));
assertEquals("{\"first\":{\"a\":\"a\"},\"second\":{\"b\":\"b\"}}", MAPPER.writer(prov).writeValueAsString(new FilteredProps()));
}
use of com.fasterxml.jackson.databind.ser.FilterProvider in project jackson-module-afterburner by FasterXML.
the class TestJsonFilter method testSimpleExclusionFilter.
public void testSimpleExclusionFilter() throws Exception {
FilterProvider prov = new SimpleFilterProvider().addFilter("RootFilter", SimpleBeanPropertyFilter.serializeAllExcept("a"));
assertEquals("{\"b\":\"b\"}", MAPPER.writer(prov).writeValueAsString(new Bean()));
}
use of com.fasterxml.jackson.databind.ser.FilterProvider in project jackson-databind by FasterXML.
the class TestJsonFilter method testSimpleExclusionFilter.
public void testSimpleExclusionFilter() throws Exception {
FilterProvider prov = new SimpleFilterProvider().addFilter("RootFilter", SimpleBeanPropertyFilter.serializeAllExcept("a"));
assertEquals("{\"b\":\"b\"}", MAPPER.writer(prov).writeValueAsString(new Bean()));
}
use of com.fasterxml.jackson.databind.ser.FilterProvider in project jackson-databind by FasterXML.
the class TestJsonFilter method testCheckSiblingContextFilter.
public void testCheckSiblingContextFilter() {
FilterProvider prov = new SimpleFilterProvider().addFilter("checkSiblingContextFilter", new CheckSiblingContextFilter());
ObjectMapper mapper = new ObjectMapper();
mapper.setFilterProvider(prov);
mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
mapper.valueToTree(new CheckSiblingContextBean());
}
Aggregations