简体   繁体   中英

Jackson mapper to persistence object

I writing JUNIT for a very complex hierarchy application I need to test a service that his input is a very large and complicated persistence object. As it so big it we decided to initialize it with JSONN string. The problem is that because it has a large Inheritance tree its getting very difficult to Jackson to de serializing it. is there a why to instruct Jackson by annotation that he will not do automatic serializing and just will do explicit. I want to ignore all filed and getters/setters except the one that with @JsonProperty annotation

Solved it by using the following config

getMapper().setVisibilityChecker(getMapper().getDeserializationConfig().getDefaultVisibilityChecker()
            .withCreatorVisibility(JsonAutoDetect.Visibility.NONE)
            .withFieldVisibility(JsonAutoDetect.Visibility.NONE)
            .withGetterVisibility(JsonAutoDetect.Visibility.NONE)
            .withIsGetterVisibility(JsonAutoDetect.Visibility.NONE)
            .withSetterVisibility(JsonAutoDetect.Visibility.NONE));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM