当前位置: 首页>>代码示例>>Java>>正文


Java ObjectMapper.setFilterProvider方法代码示例

本文整理汇总了Java中com.fasterxml.jackson.databind.ObjectMapper.setFilterProvider方法的典型用法代码示例。如果您正苦于以下问题:Java ObjectMapper.setFilterProvider方法的具体用法?Java ObjectMapper.setFilterProvider怎么用?Java ObjectMapper.setFilterProvider使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.fasterxml.jackson.databind.ObjectMapper的用法示例。


在下文中一共展示了ObjectMapper.setFilterProvider方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createMapper

import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
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;
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:24,代码来源:ConfigSupport.java

示例2: outfitMetadataFilter

import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
/**
 * Outfit the given {@link ObjectMapper} with a filter that will treat all metadata map entries as transient.
 *
 * @param om object mapper to modify
 */
private static void outfitMetadataFilter(ObjectMapper om) {
	final String filterName = "exclude-metadata";
	SimpleFilterProvider filters = new SimpleFilterProvider();
	filters.addFilter(filterName, new MetadataPropertyFilter());
	om.setAnnotationIntrospector(new JsonWrapperIntrospector(filterName));
	om.setFilterProvider(filters);
}
 
开发者ID:CMSgov,项目名称:qpp-conversion-tool,代码行数:13,代码来源:JsonWrapper.java

示例3: getErrorCode

import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
@ExceptionHandler(CerebroException.class)
@ResponseStatus(value = HttpStatus.INTERNAL_SERVER_ERROR)
public String getErrorCode(final CerebroException exception) throws IOException {
    LOGGER.error("Service error", exception);
    ObjectMapper objectMapper = new ObjectMapper();
    FilterProvider filterProvider = new SimpleFilterProvider().addFilter("responseFilter",
        SimpleBeanPropertyFilter.filterOutAllExcept("errorCode", "errorMessage"));
    objectMapper.setFilterProvider(filterProvider);
    return objectMapper.writeValueAsString(exception);
}
 
开发者ID:voyages-sncf-technologies,项目名称:cerebro,代码行数:11,代码来源:CerebroController.java


注:本文中的com.fasterxml.jackson.databind.ObjectMapper.setFilterProvider方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。