Skip to content

Commit a460d0a

Browse files
committed
Fix #377
1 parent 1b08ea6 commit a460d0a

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

parameter-names/README.md

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
Jackson module
2-
that adds support for accessing parameter names; a feature added in JDK 8.
1+
Jackson module that adds support for accessing parameter names; a feature added in JDK 8.
32

43
## Usage
54

@@ -12,6 +11,11 @@ For maven dependency definition, click on the second badge in the previous, Stat
1211
Like all standard Jackson modules (libraries that implement Module interface), registration is done as follows:
1312

1413
```java
14+
ObjectMapper mapper = JsonMapper.builder()
15+
.addModule(new ParameterNamesModule())
16+
.build();
17+
18+
// Or, older (pre-2.10):
1519
ObjectMapper mapper = new ObjectMapper();
1620
mapper.registerModule(new ParameterNamesModule());
1721
```
@@ -26,9 +30,9 @@ To override this behavior use the `ParameterNamesModule` constructor with `JsonC
2630
For example, to use same behavior as for constructors with multiple parameters:
2731
```java
2832

29-
ObjectMapper objectMapper = new ObjectMapper();
30-
objectMapper.registerModule(new ParameterNamesModule(JsonCreator.Mode.PROPERTIES));
31-
33+
ObjectMapper mapper = JsonMapper.builder()
34+
.addModule(new ParameterNamesModule(JsonCreator.Mode.PROPERTIES))
35+
.build();
3236
```
3337

3438
### Usage example
@@ -76,14 +80,15 @@ class Person {
7680

7781
Preconditions:
7882

79-
- class Person must be compiled with Java 8 compliant compiler with option to store formal parameter names turned on (`-parameters` option). For more information about Java 8 API for accessing parameter names at runtime see [this][2]
80-
- if there are multiple visible constructors and there is no default constructor, `@JsonCreator` is required to select constructor for deserialization
81-
- if used with `jackson-databind` lower than `2.6.0`, `@JsonCreator` is required. In practice, `@JsonCreator` is also often required with `2.6.0+` due to issues with constructor discovery that will be resolved in `2.7`.
82-
- if class Person has a single argument constructor, its argument needs to be annotated with `@JsonProperty("propertyName")`. This is to preserve legacy behavior, see [FasterXML/jackson-databind/#1498][3]
83+
- class Person must be compiled with Java 8 compliant compiler with option to store formal parameter names turned on (`-parameters` option). For more information about Java 8 API for accessing parameter names at runtime see [this][2]
84+
- if there are multiple visible constructors and there is no default constructor, `@JsonCreator` is required to select constructor for deserialization
85+
- if used with `jackson-databind` lower than `2.6.0`, `@JsonCreator` is required. In practice, `@JsonCreator` is also often required with `2.6.0+` due to issues with constructor discovery that will be resolved in `2.7`.
86+
- if class Person has a single-argument constructor, its argument needs to be annotated with `@JsonProperty("propertyName")`. This is to preserve legacy behavior, see [FasterXML/jackson-databind/#1498][3]
87+
8388
## More
8489

8590
See [Wiki](../../../wiki) for more information (javadocs, downloads).
8691

87-
[1]: http://jackson.codehaus.org/1.1.2/javadoc/org/codehaus/jackson/annotate/JsonProperty.html
92+
[1]: https://javadoc.io/static/com.fasterxml.jackson.core/jackson-annotations/2.20/com/fasterxml/jackson/annotation/JsonProperty.html
8893
[2]: http://docs.oracle.com/javase/tutorial/reflect/member/methodparameterreflection.html
8994
[3]: https://github.com/FasterXML/jackson-databind/issues/1498

0 commit comments

Comments
 (0)