當前位置: 首頁>>代碼示例>>Java>>正文


Java ObjectMapper.disable方法代碼示例

本文整理匯總了Java中com.fasterxml.jackson.databind.ObjectMapper.disable方法的典型用法代碼示例。如果您正苦於以下問題:Java ObjectMapper.disable方法的具體用法?Java ObjectMapper.disable怎麽用?Java ObjectMapper.disable使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.fasterxml.jackson.databind.ObjectMapper的用法示例。


在下文中一共展示了ObjectMapper.disable方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createObjectMapper

import com.fasterxml.jackson.databind.ObjectMapper; //導入方法依賴的package包/類
private static ObjectMapper createObjectMapper() {

        ObjectMapper mapper = new ObjectMapper();

        mapper.registerModule(new Jdk8Module());
        mapper.registerModule(new JavaTimeModule());
        mapper.registerModule(new ParameterNamesModule());

        mapper.enable(SerializationFeature.INDENT_OUTPUT);
        mapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS);
        mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);

        mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
        mapper.enable(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT);

        return mapper;
    }
 
開發者ID:cassiomolin,項目名稱:jersey-jwt-springsecurity,代碼行數:18,代碼來源:ObjectMapperProvider.java

示例2: map

import com.fasterxml.jackson.databind.ObjectMapper; //導入方法依賴的package包/類
@Override
public <T> T map(String json, Class<T> clazz) {
    if (null == json) {
        throw new IllegalArgumentException("Can not map empty json");
    }
    ObjectMapper mapper = new ObjectMapper();
    mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
    mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
    JsonUnmarshaller jsonUnmarshaller = new FixedDefaultJsonUnmarshaller(mapper);
    try {
        return jsonUnmarshaller.unmarshal(clazz, json);
    } catch (IOException e) {
        log.warn("Error during mapping", e);
        return null;
    }
}
 
開發者ID:xm-online,項目名稱:xm-ms-entity,代碼行數:17,代碼來源:ElasticPathStrategy.java

示例3: configure

import com.fasterxml.jackson.databind.ObjectMapper; //導入方法依賴的package包/類
@Override
public void configure(Map configs, boolean isKey) {
    String documentBasePackage = (String) configs.get("documentBasePackage");

    SimpleModule module = new SimpleModule();
    Set<Class<?>> annotatedClasses = ClassUtils.getAnnotatedClasses(documentBasePackage, Document.class);
    annotatedClasses.forEach(aClass -> module.addSerializer(aClass, new MetaableJkesJsonSerializer<>()));

    ObjectMapper mapper = new ObjectMapper();
    mapper.registerModule(module);

    // mapper.enable(SerializationFeature.INDENT_OUTPUT);
    mapper.enable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); // Feature is enabled by default, so that date/time are by default serialized as timestamps.
    mapper.disable(SerializationFeature.WRITE_NULL_MAP_VALUES);

    this.mapper = mapper;
}
 
開發者ID:chaokunyang,項目名稱:jkes,代碼行數:18,代碼來源:JkesKafkaJsonSerializer.java

示例4: jsonSerialization

import com.fasterxml.jackson.databind.ObjectMapper; //導入方法依賴的package包/類
/**
 * Serialize a list of objects with a particular set of attributes
 * @param view
 * @return
 * @throws IOException 
 */
public JsonNode jsonSerialization(Class view) throws IOException
{
    ObjectMapper mapper = new ObjectMapper();
    
    DateFormat myDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS");
    mapper.setDateFormat(myDateFormat); 
    mapper.disable(MapperFeature.DEFAULT_VIEW_INCLUSION);
    
    ObjectWriter writer = mapper.writerWithView(view);
    JsonNode response = mapper.readTree(writer.writeValueAsString(this));
    return response;
}
 
開發者ID:ejesposito,項目名稱:CS6310O01,代碼行數:19,代碼來源:Record.java

示例5: JsonMapper

import com.fasterxml.jackson.databind.ObjectMapper; //導入方法依賴的package包/類
public JsonMapper(Include include) {
    mapper = new ObjectMapper();
    //設置輸出時包含屬性的風格
    if (include != null) {
        mapper.setSerializationInclusion(include);
    }
    //設置輸入時忽略在JSON字符串中存在但Java對象實際沒有的屬性
    mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
    //
    mapper.configure(Feature.ALLOW_UNQUOTED_FIELD_NAMES, false);
}
 
開發者ID:warlock-china,項目名稱:azeroth,代碼行數:12,代碼來源:JsonMapper.java

示例6: provideObjectMapper

import com.fasterxml.jackson.databind.ObjectMapper; //導入方法依賴的package包/類
@Provides
@Singleton
ObjectMapper provideObjectMapper() {
  ObjectMapper objectMapper = new ObjectMapper();

  objectMapper.setPropertyNamingStrategy(
      PropertyNamingStrategy.CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES);
  objectMapper.setSerializationInclusion(JsonInclude.Include.NON_ABSENT);
  objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
  objectMapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);

  return objectMapper;
}
 
開發者ID:cerner,項目名稱:beadledom,代碼行數:14,代碼來源:FauxModule.java

示例7: JsonMapper

import com.fasterxml.jackson.databind.ObjectMapper; //導入方法依賴的package包/類
public JsonMapper(Include include) {
	mapper = new ObjectMapper();
	// 設置輸出時包含屬性的風格
	if (include != null) {
		mapper.setSerializationInclusion(include);
	}
	// 設置輸入時忽略在JSON字符串中存在但Java對象實際沒有的屬性
	mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
}
 
開發者ID:zhangjunfang,項目名稱:util,代碼行數:10,代碼來源:JsonMapper.java

示例8: objectMapper

import com.fasterxml.jackson.databind.ObjectMapper; //導入方法依賴的package包/類
@Bean
public ObjectMapper objectMapper() {
	ObjectMapper mapper = new ObjectMapper();
	mapper.setDateFormat(DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM, Locale.CHINA));
	mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
	return mapper;
}
 
開發者ID:wengwh,項目名稱:plumdo-stock,代碼行數:8,代碼來源:ApplicationConfig.java

示例9: createDefaultObjectMapper

import com.fasterxml.jackson.databind.ObjectMapper; //導入方法依賴的package包/類
private static ObjectMapper createDefaultObjectMapper() {
    final ObjectMapper objectMapper = new ObjectMapper();
    objectMapper.setPropertyNamingStrategy(PropertyNamingStrategy.SNAKE_CASE);
    objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
    objectMapper.registerModules(new Jdk8Module(), new ParameterNamesModule(), new JavaTimeModule());
    objectMapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
    return objectMapper;
}
 
開發者ID:zalando-nakadi,項目名稱:nakadi-producer-spring-boot-starter,代碼行數:9,代碼來源:MockNakadiPublishingClient.java

示例10: getObjectMapper

import com.fasterxml.jackson.databind.ObjectMapper; //導入方法依賴的package包/類
@Override
    public ObjectMapper getObjectMapper() {
        ObjectMapper objectMapper = new ObjectMapper();
        objectMapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS);
//            objectMapper.disable(SerializationFeature.FLUSH_AFTER_WRITE_VALUE);
        objectMapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
        objectMapper.setTimeZone(TimeZone.getDefault());
        return objectMapper;
    }
 
開發者ID:yunhaibin,項目名稱:dubbox-hystrix,代碼行數:10,代碼來源:DefaultJacksonObjectMapperProvider.java

示例11: createMapper

import com.fasterxml.jackson.databind.ObjectMapper; //導入方法依賴的package包/類
ObjectMapper createMapper() {
    ObjectMapper mapper = new ObjectMapper();
    mapper.registerModules(new Jdk8Module(), new JavaTimeModule());
    mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
    mapper.enable(SerializationFeature.INDENT_OUTPUT);
    return mapper;
}
 
開發者ID:goodees,項目名稱:goodees,代碼行數:8,代碼來源:ImmutableEventTest.java

示例12: configureMessageConverters

import com.fasterxml.jackson.databind.ObjectMapper; //導入方法依賴的package包/類
@Override
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
    final MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter();
    final ObjectMapper objectMapper = new ObjectMapper();
    objectMapper.configure(SerializationFeature.INDENT_OUTPUT, true);
    objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
    objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
    objectMapper.registerModule(new JavaTimeModule());
    converter.setObjectMapper(objectMapper);
    converters.add(converter);
    super.configureMessageConverters(converters);
}
 
開發者ID:mintster,項目名稱:nixmash-blog,代碼行數:13,代碼來源:WebConfig.java

示例13: buildDefaultObjectMapper

import com.fasterxml.jackson.databind.ObjectMapper; //導入方法依賴的package包/類
private static synchronized void buildDefaultObjectMapper() {
        objectMapper = new ObjectMapper();
        objectMapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS);
//            objectMapper.disable(SerializationFeature.FLUSH_AFTER_WRITE_VALUE);
        objectMapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
        objectMapper.setTimeZone(TimeZone.getDefault());
    }
 
開發者ID:yunhaibin,項目名稱:dubbox-hystrix,代碼行數:8,代碼來源:Jackson.java

示例14: initClassStubData

import com.fasterxml.jackson.databind.ObjectMapper; //導入方法依賴的package包/類
@BeforeClass
public static void initClassStubData() {
  mapper = new ObjectMapper();
  mapper.disable(MapperFeature.AUTO_DETECT_GETTERS);
  mapper.disable(MapperFeature.AUTO_DETECT_IS_GETTERS);
  mapper.disable(MapperFeature.AUTO_DETECT_FIELDS);
  mapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS);
  treeMapSerializer = new TreeMapSerializer();
}
 
開發者ID:twosigma,項目名稱:beaker-notebook-archive,代碼行數:10,代碼來源:TreeMapSerializerTest.java

示例15: customObjectMapperForSpring

import com.fasterxml.jackson.databind.ObjectMapper; //導入方法依賴的package包/類
/**
 * Example how skip auto-configuration and use a custom ObjectMapper.
 * Also can use a Jackson2ObjectMapperBuilder bean for the same purpose.
 */
//@Bean
ObjectMapper customObjectMapperForSpring() {
	ObjectMapper mapper = new ObjectMapper();
	JavaTimeModule javaTimeModule = new JavaTimeModule();
	javaTimeModule.addSerializer(new LocalDateTimeSerializer(DateTimeFormatter.ofPattern("YYYY-MMM")));
	mapper.registerModule(javaTimeModule);
	mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
	mapper.setDateFormat(new SimpleDateFormat("YYYY"));
	return mapper;
}
 
開發者ID:bszeti,項目名稱:camel-springboot,代碼行數:15,代碼來源:AppConfig.java


注:本文中的com.fasterxml.jackson.databind.ObjectMapper.disable方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。