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


Java ObjectMapper.setVisibility方法代码示例

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


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

示例1: redisTemplate

import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
@Bean(name="redisTemplate")
public RedisTemplate<String, String> redisTemplate(RedisConnectionFactory factory) {

    RedisTemplate<String, String> template = new RedisTemplate<>();


    RedisSerializer<String> redisSerializer = new StringRedisSerializer();

    Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer(Object.class);
    ObjectMapper om = new ObjectMapper();
    om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
    om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
    jackson2JsonRedisSerializer.setObjectMapper(om);

    template.setConnectionFactory(factory);
    //key序列化方式
    template.setKeySerializer(redisSerializer);
    //value序列化
    template.setValueSerializer(jackson2JsonRedisSerializer);
    //value hashmap序列化
    template.setHashValueSerializer(jackson2JsonRedisSerializer);

    return template;
}
 
开发者ID:cwenao,项目名称:springboot_cwenao,代码行数:25,代码来源:RedisConfig.java

示例2: initializeObjectMapper

import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
@Override
protected ObjectMapper initializeObjectMapper() {
    final ObjectMapper mapper = super.initializeObjectMapper();

    final FilterProvider filters = new SimpleFilterProvider()
            .addFilter("beanObjectFilter", new CasSimpleBeanObjectFilter());
    mapper.setFilters(filters);

    mapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
    mapper.configure(SerializationFeature.WRITE_EMPTY_JSON_ARRAYS, false);
    mapper.configure(SerializationFeature.WRITE_NULL_MAP_VALUES, false);
    mapper.setSerializationInclusion(JsonInclude.Include.NON_EMPTY);
    mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
    mapper.addMixIn(Object.class, CasSimpleBeanObjectFilter.class);
    mapper.disable(SerializationFeature.INDENT_OUTPUT);
    mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);

    return mapper;
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:20,代码来源:InternalConfigStateController.java

示例3: redisTemplate

import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
/**
 * RedisTemplate配置
 * @param factory
 * @return
 */
@Bean
@SuppressWarnings({"rawtypes", "unchecked"})
public RedisTemplate<String, String> redisTemplate(RedisConnectionFactory factory) {
    StringRedisTemplate template = new StringRedisTemplate(factory);
    //定义value的序列化方式
    Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer(Object.class);
    ObjectMapper om = new ObjectMapper();
    om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
    om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
    jackson2JsonRedisSerializer.setObjectMapper(om);
    
    template.setValueSerializer(jackson2JsonRedisSerializer);
    template.setHashValueSerializer(jackson2JsonRedisSerializer);
    template.afterPropertiesSet();
    return template;
}
 
开发者ID:SnailFastGo,项目名称:springboot_op,代码行数:22,代码来源:RedisConfiguration.java

示例4: execute

import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
@Override
public void execute() {

    Path taxonomyDefinitionImportPath = executionParameters.getTaxonomyDefinitionImportPath();
    Path taxonomyDefinitionOutputPath = executionParameters.getTaxonomyDefinitionOutputPath();
    assertRequiredArgs(taxonomyDefinitionImportPath, taxonomyDefinitionOutputPath);

    taxonomyMigrator.init();
    TaxonomyTerm taxonomyDefinition = taxonomyMigrator.getTaxonomyDefinition();

    // Write out the JSON files
    try {
        ObjectMapper mapper = new ObjectMapper();
        mapper.setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY);
        File dir = taxonomyDefinitionOutputPath.toFile();
        dir.mkdirs();
        // Prefix is so taxonomy gets imported first, before any documents
        mapper.writeValue(new File(dir, "000000_" + "publication_taxonomy.json"), taxonomyDefinition);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:NHS-digital-website,项目名称:hippo,代码行数:23,代码来源:GenerateTaxonomyTask.java

示例5: shouldRoundTripQuotedPrintableFieldWithNoFieldVisibility

import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
@Test
public void shouldRoundTripQuotedPrintableFieldWithNoFieldVisibility() throws Exception {
    ObjectMapper mapper = new ObjectMapper();
    mapper.setVisibility(mapper.getVisibilityChecker().withFieldVisibility(Visibility.NONE));

    roundTripAssertions(
            new ObjectMapper(),
            "anyBinaryEncoding",
            "\"=E3=82=A8=E3=83=B3=E3=82=B3=E3=83=BC=E3=83=89=E3=81=95=E3=82=8C=E3=81=9F=E6=96=87=E5=AD=97=E5=88=97\" is Japanese for \"encoded string\"",
            "\"エンコードされた文字列\" is Japanese for \"encoded string\"".getBytes("UTF-8"));
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:12,代码来源:MediaIT.java

示例6: initializeObjectMapper

import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
/**
 * Initialize object mapper.
 *
 * @return the object mapper
 */
protected ObjectMapper initializeObjectMapper() {
    final ObjectMapper mapper = new ObjectMapper();
    mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
    mapper.setSerializationInclusion(JsonInclude.Include.NON_EMPTY);
    mapper.setVisibility(PropertyAccessor.SETTER, JsonAutoDetect.Visibility.PROTECTED_AND_PUBLIC);
    mapper.setVisibility(PropertyAccessor.GETTER, JsonAutoDetect.Visibility.PROTECTED_AND_PUBLIC);
    mapper.setVisibility(PropertyAccessor.IS_GETTER, JsonAutoDetect.Visibility.PROTECTED_AND_PUBLIC);
    mapper.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL, JsonTypeInfo.As.PROPERTY);
    return mapper;
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:16,代码来源:AbstractJacksonBackedJsonSerializer.java

示例7: template

import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
@Bean
public HwRedisTemplate template(HwRedisConnectionFactory factory) {
    // 序列化
    Jackson2JsonRedisSerializer<Object> jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer<Object>(Object.class);
    ObjectMapper om = new ObjectMapper();
    om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
    om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
    jackson2JsonRedisSerializer.setObjectMapper(om);
    // 实例化template
    HwRedisTemplate hwRedisTemplate = new HwRedisTemplate();
    hwRedisTemplate.setConnectionFactory(factory);
    hwRedisTemplate.setValueSerializer(jackson2JsonRedisSerializer);
    return hwRedisTemplate;
}
 
开发者ID:Fourwenwen,项目名称:consistent-hashing-redis,代码行数:15,代码来源:CacheConfig.java

示例8: redisTemplate

import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
@SuppressWarnings({"unchecked","rawtypes"})
@Bean  
   public RedisTemplate<String, String> redisTemplate(  
           RedisConnectionFactory factory) {  
       StringRedisTemplate template = new StringRedisTemplate(factory);  
	Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer(Object.class);  
       ObjectMapper om = new ObjectMapper();  
       om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);  
       om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);  
       jackson2JsonRedisSerializer.setObjectMapper(om);  
       template.setValueSerializer(jackson2JsonRedisSerializer);  
       template.afterPropertiesSet();  
       return template;  
   }
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:15,代码来源:RedisConfig.java

示例9: configureObjectMapper

import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
/**
 * Configure mapper.
 *
 * @param mapper the mapper
 */
protected void configureObjectMapper(final ObjectMapper mapper) {
    mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false)
            .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);

    mapper.setSerializationInclusion(JsonInclude.Include.NON_EMPTY);
    mapper.setVisibility(PropertyAccessor.SETTER, JsonAutoDetect.Visibility.PROTECTED_AND_PUBLIC);
    mapper.setVisibility(PropertyAccessor.GETTER, JsonAutoDetect.Visibility.PROTECTED_AND_PUBLIC);
    mapper.setVisibility(PropertyAccessor.IS_GETTER, JsonAutoDetect.Visibility.PROTECTED_AND_PUBLIC);

    if (isDefaultTypingEnabled()) {
        mapper.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL, JsonTypeInfo.As.PROPERTY);
    }
    mapper.findAndRegisterModules();
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:20,代码来源:AbstractJacksonBackedStringSerializer.java

示例10: getObjectMapperInstance

import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
/**
 * Get the standard {@link ObjectMapper} instance used for parsing {@code index-v1.json}.
 * This ignores unknown properties so that old releases won't crash when new things are
 * added to {@code index-v1.json}.  This is required for both forward compatibility,
 * but also because ignoring such properties when coming from a malicious server seems
 * reasonable anyway.
 */
public static ObjectMapper getObjectMapperInstance(long repoId) {
    ObjectMapper mapper = new ObjectMapper();
    mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
    mapper.setInjectableValues(new InjectableValues.Std().addValue("repoId", repoId));
    mapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.NONE);
    mapper.setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.PUBLIC_ONLY);
    return mapper;
}
 
开发者ID:uhuru-mobile,项目名称:mobile-store,代码行数:16,代码来源:IndexV1Updater.java

示例11: importAnnotationQueries

import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
private static AnnotationQueries importAnnotationQueries(String annotationFile){
	
       //initialize JSON-Object mapper
	ObjectMapper mapper = new ObjectMapper();
       mapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.NONE);
       //use all fields
       mapper.setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY);
       //only include not null & non empty fields
       mapper.setSerializationInclusion(JsonInclude.Include.NON_EMPTY);
       //store type of classess also
       mapper.enableDefaultTypingAsProperty(ObjectMapper.DefaultTyping.NON_FINAL, "@class");
       //ignore unknown properties
       mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
       mapper.configure(DeserializationFeature.FAIL_ON_UNRESOLVED_OBJECT_IDS, false);
       mapper.configure(DeserializationFeature.FAIL_ON_INVALID_SUBTYPE, false);

	AnnotationQueries q = null;
	
	try {

		q = mapper.readValue(new FileInputStream(new File(annotationFile)), AnnotationQueries.class); //read JSON from URL
		
	} catch (IOException e1) {
		e1.printStackTrace();
	}

	return q;
}
 
开发者ID:onprom,项目名称:onprom,代码行数:29,代码来源:LogExtractorUsageExample3.java

示例12: redisTemplate

import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
@Bean
public RedisTemplate<String, String> redisTemplate(RedisConnectionFactory factory) {
    StringRedisTemplate template = new StringRedisTemplate(factory);
    Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer(Object.class);
    ObjectMapper om = new ObjectMapper();
    om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
    om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
    jackson2JsonRedisSerializer.setObjectMapper(om);
    template.setValueSerializer(jackson2JsonRedisSerializer);
    template.afterPropertiesSet();
    return template;
}
 
开发者ID:ChinaLHR,项目名称:JavaQuarkBBS,代码行数:13,代码来源:RedisConfig.java

示例13: setSerializer

import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
@SuppressWarnings({ "unchecked", "rawtypes" })
  private void setSerializer(RedisTemplate<String, Object> template) {
Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer(Object.class);
      ObjectMapper om = new ObjectMapper();
      om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
      om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
      jackson2JsonRedisSerializer.setObjectMapper(om);
      template.setKeySerializer(new StringRedisSerializer());
      //template.setValueSerializer(jackson2JsonRedisSerializer);		//-- 值序列化为json
      template.setValueSerializer(new RedisObjectSerializer());       //-- 默认序列化为byte[]
  }
 
开发者ID:ranji1221,项目名称:lemcloud,代码行数:12,代码来源:RedisConfig.java

示例14: init

import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
/**
 * Initialize a {@code SmsService} instance.
 *
 * @param id The LC id
 * @param key The LC key
 */
public void init(String id, String key) {
    StringHttpMessageConverter converter = new StringHttpMessageConverter(Charset.forName("UTF-8"));
    converter.setWriteAcceptCharset(false);
    restTemplate = new RestTemplate();
    restTemplate.getMessageConverters().add(0, converter);
    mapper = new ObjectMapper();
    mapper.setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY);
    headers = new HttpHeaders();
    headers.add("X-LC-Id", id);
    headers.add("X-LC-Key", key);
    headers.setContentType(MediaType.APPLICATION_JSON);
}
 
开发者ID:AwesomeTickets,项目名称:ServiceServer,代码行数:19,代码来源:SmsService.java

示例15: serializeFieldsOnly

import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
public static void serializeFieldsOnly(Object value, boolean pretty, OutputStream out) throws IOException {
    ObjectMapper mapper = createMapper(pretty);
    mapper.setVisibility(fieldsOnlyVisibilityChecker(mapper));
    mapper.writeValue(out, value);
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:6,代码来源:Serializers.java


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