https://github.com/gwllx/jackson-invert
A Jackson module to invert JSON object-of-arrays into Java array-of-objects.
https://github.com/gwllx/jackson-invert
jackson jackson-module java json
Last synced: about 2 months ago
JSON representation
A Jackson module to invert JSON object-of-arrays into Java array-of-objects.
- Host: GitHub
- URL: https://github.com/gwllx/jackson-invert
- Owner: gwllx
- License: mit
- Created: 2023-10-10T18:39:39.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-10-22T20:43:34.000Z (over 2 years ago)
- Last Synced: 2023-10-22T21:26:10.770Z (over 2 years ago)
- Topics: jackson, jackson-module, java, json
- Language: Java
- Homepage:
- Size: 10.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Jackson Invert
A Jackson module to invert JSON object-of-arrays into Java array-of-objects.
## Example
Given the JSON input:
```json
{
"people": {
"name": ["Bill", "Bob"],
"age": [20, 30]
}
}
```
The ``@JsonInvert`` annotation can be used to deserialize the following model:
```java
public record Wrapper(@JsonInvert List people) {}
public record Person(String name, int age) {}
```
## Usage
The ``InvertModule`` should be registered with a Jackson ``ObjectMapper``:
```java
var objectMapper = new ObjectMapper().registerModule(new InvertModule());
```