Java Code Examples for com.fasterxml.jackson.databind.ObjectMapper#copy()

The following examples show how to use com.fasterxml.jackson.databind.ObjectMapper#copy() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ElasticsearchConfiguration.java    From spring-rdbms-cdc-kafka-elasticsearch with Apache License 2.0 5 votes vote down vote up
CustomEntityMapper(ObjectMapper objectMapper) {
  // clone the current object mapper that have JSR-310 modules registred
  this.objectMapper = objectMapper.copy();

  this.objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
  this.objectMapper.configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true);
  this.objectMapper.registerModule(new CustomGeoModule());
}
 
Example 2
Source File: ElasticsearchConfiguration.java    From spring-rdbms-cdc-kafka-elasticsearch with Apache License 2.0 5 votes vote down vote up
CustomEntityMapper(ObjectMapper objectMapper) {
  // clone the current object mapper that have JSR-310 modules registred
  this.objectMapper = objectMapper.copy();

  this.objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
  this.objectMapper.configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true);
  this.objectMapper.registerModule(new CustomGeoModule());
}
 
Example 3
Source File: MappingApiJackson2HttpMessageConverter.java    From blade-tool with GNU Lesser General Public License v3.0 5 votes vote down vote up
private static ObjectMapper initWriteObjectMapper(ObjectMapper readObjectMapper) {
	// 拷贝 readObjectMapper
	ObjectMapper writeObjectMapper = readObjectMapper.copy();
	// null 处理
	writeObjectMapper.setSerializerFactory(writeObjectMapper.getSerializerFactory().withSerializerModifier(new BladeBeanSerializerModifier()));
	writeObjectMapper.getSerializerProvider().setNullValueSerializer(BladeBeanSerializerModifier.NullJsonSerializers.STRING_JSON_SERIALIZER);
	return writeObjectMapper;
}
 
Example 4
Source File: AppConfigService.java    From haven-platform with Apache License 2.0 5 votes vote down vote up
@Autowired
public AppConfigService(KvMapperFactory kvMapperFactory, ObjectMapper objectMapper) {
    // we must use custom configuration of mapper, but need use most options and modules from global mapper
    this.objectMapper = objectMapper.copy();
    StdTypeResolverBuilder trb = new ObjectMapper.DefaultTypeResolverBuilder(ObjectMapper.DefaultTyping.JAVA_LANG_OBJECT);
    trb.init(JsonTypeInfo.Id.CLASS, new CustomTypeIdResolver()).inclusion(JsonTypeInfo.As.PROPERTY);
    this.objectMapper.setDefaultTyping(trb);
    this.objectMapper.registerModule(new KvSupportModule(kvMapperFactory));
}
 
Example 5
Source File: DatabaseSessionStoreManager.java    From digdag with Apache License 2.0 5 votes vote down vote up
@Inject
public DatabaseSessionStoreManager(ConfigFactory cf, TransactionManager transactionManager, ConfigMapper cfm, ObjectMapper mapper, DatabaseConfig config)
{
    super(config.getType(), dao(config.getType()), transactionManager, cfm);

    this.taskArchiveMapper = mapper.copy();
    this.taskArchiveMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);

    this.cf = cf;
    this.stm = new StoredTaskMapper(cfm);
    this.atm = new ArchivedTaskMapper(cklm, cfm);
    this.tasm = new TaskAttemptSummaryMapper();
}
 
Example 6
Source File: JacksonContextResolver.java    From onedev with MIT License 4 votes vote down vote up
@Inject
public JacksonContextResolver(ObjectMapper objectMapper) {
	this.objectMapper = objectMapper.copy();
	this.objectMapper.setConfig(this.objectMapper.getSerializationConfig().withView(RestView.class));
}
 
Example 7
Source File: WebHookManager.java    From onedev with MIT License 4 votes vote down vote up
@Inject
public WebHookManager(ObjectMapper mapper, ExecutorService executor) {
	this.mapper = mapper.copy();
	this.mapper.setConfig(this.mapper.getSerializationConfig().withView(RestView.class));
	this.executor = executor;
}
 
Example 8
Source File: DefaultHashComputer.java    From terracotta-platform with Apache License 2.0 4 votes vote down vote up
public DefaultHashComputer(ObjectMapper mapper) {
  this.mapper = mapper.copy();
  this.mapper.configure(SerializationFeature.INDENT_OUTPUT, false);
}
 
Example 9
Source File: LogbookExtraConfig.java    From fullstop with Apache License 2.0 4 votes vote down vote up
@Bean
public HttpLogFormatter httpFormatter(final ObjectMapper objectMapper) {
    ObjectMapper mapper = objectMapper.copy();
    mapper = mapper.disable(INDENT_OUTPUT);
    return new JsonHttpLogFormatter(mapper);
}
 
Example 10
Source File: ServerModule.java    From digdag with Apache License 2.0 4 votes vote down vote up
@Inject
public JsonProviderProvider(ObjectMapper mapper)
{
    this.mapper = mapper.copy();
    this.mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
}
 
Example 11
Source File: JsonViewSupportFactoryBean.java    From json-view with GNU General Public License v3.0 4 votes vote down vote up
public JsonViewSupportFactoryBean(ObjectMapper mapper) {
  this(new JsonViewMessageConverter(mapper.copy()), DefaultView.create());
}
 
Example 12
Source File: JsonViewSupportFactoryBean.java    From json-view with GNU General Public License v3.0 4 votes vote down vote up
public JsonViewSupportFactoryBean(ObjectMapper mapper, DefaultView defaultView) {
  this(new JsonViewMessageConverter(mapper.copy()), defaultView);
}
 
Example 13
Source File: JsonJacksonCodec.java    From redisson with Apache License 2.0 4 votes vote down vote up
public JsonJacksonCodec(ObjectMapper mapObjectMapper) {
    this.mapObjectMapper = mapObjectMapper.copy();
    init(this.mapObjectMapper);
    initTypeInclusion(this.mapObjectMapper);
}