當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。