code: public static SimpleModule getModule(final ObjectMapper mapper) {
          SimpleModule module = new SimpleModule();
          module.setSerializerModifier(new BeanSerializerModifier() {
              @Override
              public JsonSerializer<?> modifySerializer(SerializationConfig config, BeanDescription beanDesc, JsonSerializer<?> serializer) {
                  if (beanDesc.getBeanClass().getAnnotation(JsonFlatten.class) != null) {
                      return new FlatteningSerializer(beanDesc.getBeanClass(), serializer, mapper);
                  }
                  return serializer;
              }
          });
          return module;
      }
docs: Gets a module wrapping this serializer as an adapter for the Jackson
  ObjectMapper.
  
  @param mapper the object mapper for default serializations
  @return a simple module to be plugged onto Jackson ObjectMapper.