本文整理汇总了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;
}
示例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;
}
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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());
}
示例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();
}
示例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;
}