Skip to content

livingobjects/jackson-module-parameter-names

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Jackson module that adds support for accessing parameter names; a feature added in JDK 8.

Status

This is a new, experimental module; 2.4 is the first official release.

Build Status

Usage

Maven dependency

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)

Registering module

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.

Usage example

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.

More

See Wiki for more information (javadocs, downloads).

About

Extension module that adds support for JDK8 datatypes before core Jackson can support them (currently JDK baseline is 6)

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors