Micronaut uses Jackson to encode objects to JSON and decode JSON to objects. Micronaut adds a Jackson
ObjectMapper bean to the application context with all configuration to work properly. Jackson can by default populate an object with values from JSON as the class has a no argument constructor and the properties can be accessed. But if our class doesn’t have a no argument constructor we need to use the
@JsonProperty annotations to help Jackson. We can use these annotation on the constructor with arguments that is used to create an object.
But we can even make it work without the extra annotations, so our classes are easier to read and better reusable. We need to add the Jackson
ParameterNamesModule as module to the
ObjectMapper instance in our application. And we need to compile our sources with the
-parameter argument, so the argument names are preserved in the compiled code. Luckily the
-parameter option is already added to our Gradle build when we create a Micronaut application. All we have to do is to add the
ParameterNamesModule in our application.