Skip to content

A Jackson module to invert objects-of-arrays into arrays-of-objects.

License

Notifications You must be signed in to change notification settings

gwllx/jackson-invert

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Jackson Invert

A Jackson module to invert JSON object-of-arrays into Java array-of-objects.

Example

Given the JSON input:

{
  "people": {
    "name": ["Bill", "Bob"],
    "age": [20, 30]
  }
}

The @JsonInvert annotation can be used to deserialize the following model:

public record Wrapper(@JsonInvert List<Person> people) {}
public record Person(String name, int age) {}

Usage

The InvertModule should be registered with a Jackson ObjectMapper:

var objectMapper = new ObjectMapper().registerModule(new InvertModule());

About

A Jackson module to invert objects-of-arrays into arrays-of-objects.

Topics

Resources

License

Stars

Watchers

Forks

Languages