本文整理匯總了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;
}