Skip to content

Instantly share code, notes, and snippets.

@marcus-nl
Created August 16, 2014 10:08
Show Gist options
  • Save marcus-nl/8c5c6f8472cced934144 to your computer and use it in GitHub Desktop.
Save marcus-nl/8c5c6f8472cced934144 to your computer and use it in GitHub Desktop.
Jackson: register subtypes using Reflections
private void registerSubtypes(ObjectMapper objectMapper, Class<?> base) {
Reflections reflections = new Reflections(base.getPackage().getName());
Class<?>[] subTypes = reflections.getSubTypesOf(base).toArray(new Class<?>[0]);
objectMapper.registerSubtypes(subTypes);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment