当前位置: 首页>>代码示例>>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;未经允许,请勿转载。