A Jackson module to invert JSON object-of-arrays into Java array-of-objects.
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) {}The InvertModule should be registered with a Jackson ObjectMapper:
var objectMapper = new ObjectMapper().registerModule(new InvertModule());