Jackson module that adds support for accessing parameter names; a feature added in JDK 8.
This is a new, experimental module; 2.4 is the first official release.
To use module on Maven-based projects, use following dependency:
<dependency>
<groupId>com.fasterxml.jackson.module</groupId>
<artifactId>jackson-module-parameter-names</artifactId>
<version>2.4.0</version>
</dependency>(or whatever version is most up-to-date at the moment)
Like all standard Jackson modules (libraries that implement Module interface), registration is done as follows:
ObjectMapper mapper = new ObjectMapper();
mapper.registerModule(new ParameterNamesModule());after which functionality is available for all normal Jackson operations.
Java 8 API adds support for accessing parameter names at runtime in order to enable clients to abandon the JavaBeans standard if they want to without forcing them to use annotations (such as JsonProperty).
So, after registering the module as described above, you will be able to use data binding with a class like
class Person {
private final String name;
private final String surname;
@JsonCreator // important!
public Person(String name, String surname) {
this.name = name;
this.surname = surname;
}
public String getName() {
return name;
}
public String getSurname() {
return surname;
}
}class Person must be compiled with Java 8 compliant compiler with the enabled option to store formal parameter names (-parameters option). For more information about Java 8 API for accessing parameter names at runtime see this.
See Wiki for more information (javadocs, downloads).