'while doing Json.encodePrettily(object) in vertx null values are also getting included

while doing Json.encodePrettily(object) in vertx null values are also getting included.

so need to know how we can configure it to avoid null values in response.



Solution 1:[1]

io.vertx.core.json is implemented using jackson fasterxml so vertx internally uses jackson fasterxml library. So unless explicitly required there is no need to use any other json library with vertx.

so to avoid same we can use following

Json.prettyMapper.setSerializationInclusion(Include.NON_NULL);

Solution 2:[2]

You can also add @JsonInclude(JsonInclude.Include.NON_NULL) at the top of your model class.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Kishore Tulsiani
Solution 2 Stempler