Java Spring Boot apply configuration for FasterXml Jackson library -


i have spring boot project maven dependency: com.fasterxml.jackson.datatype

and want enable 2 properties accept_empty_string_as_null_object , fail_on_reading_dup_tree_key.

but fail 2 enable them in 2 different ways: 1) application.yml

  jackson:          serialization:              write_dates_as_timestamps: false          deserialization:               fail_on_reading_dup_tree_key: true 

2) adding them configuration bean

@configuration public class jacksonconfiguration {      @autowired     private objectmapper objectmapper;      @postconstruct     private void configureobjectmapper() {         objectmapper.enable(deserializationfeature.accept_empty_string_as_null_object );         objectmapper.enable(deserializationfeature.fail_on_reading_dup_tree_key );     } } 

neither 1 of ways gave me desired effect. please advice correct way how it?

create , configure objectmapper scratch:

@configuration public class jacksonconfiguration {      @bean     public objectmapper objectmapper() {         return new objectmapper()                 .enable(deserializationfeature.accept_empty_string_as_null_object )                 .enable(deserializationfeature.fail_on_reading_dup_tree_key );     } } 

Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -