title: Duplicate JSON field when serializing field using Jackson
body: <p>I want to create an Jackson objectmapper module, which will serialize all fields annotated with <code>@Encrypt</code> to a single field. However  <code>BeanPropertyWriter:serializeAsField(Object bean, JsonGenerator jgen, SerializerProvider prov)</code> only supports single field handling.</p>
  <p>Let's assume we have an POJO:</p>
  <pre class="lang-java prettyprint-override"><code>public static class Pojo {
          @Encrypt public String foo;
          @Encrypt public String bar;
  }
  </code></pre>
  <p>I've configured an module for my objectmapper as following:</p>
  <pre class="lang-java prettyprint-override"><code>public class CustomSimpleModule extends SimpleModule {
    @Override
    public void setupModule(final Module.SetupContext context) {
      super.setupModule(context);
      context.addBeanSerializerModifier(new CustomBeanSerializerModifier());
    }
  
    private static class CustomBeanSerializerModifier extends BeanSerializerModifier {
      @Override
      public List&lt;BeanPropertyWriter&gt; changeProperties(final SerializationConfig config, final BeanDescription beanDesc, final List&lt;BeanPropertyWriter&gt; beanProperties) {
        beanProperties.replaceAll(
            property -&gt; Objects.nonNull(property.getAnnotation(EncryptInLogs.class)) ? new CustomBeanPropertyWriter(property) : property);
        return beanProperties;
      }
    }
  
    private static class CustomBeanPropertyWriter extends BeanPropertyWriter {
      protected CustomBeanPropertyWriter(final BeanPropertyWriter writer) {
        super(writer);
      }
      
      @Override
      public void serializeAsField(
          final Object bean, final JsonGenerator jgen, final SerializerProvider prov)
          throws Exception {
        jgen.writeFieldName(&quot;encrypted&quot;);
        jgen.writeStartObject();
        super.serializeAsField(bean, jgen, prov);
        jgen.writeEndObject();
      }
    }
  }
  </code></pre>
  <p>When serializing the <code>POJO</code> it gives invalid JSON:</p>
  <pre class="lang-json prettyprint-override"><code>{
    &quot;encrypted&quot;: {
      &quot;foo&quot;: &quot;foo&quot;
    },
    &quot;encrypted&quot;: {
      &quot;bar&quot;: &quot;bar&quot;
    }
  }
  </code></pre>
  <p>Is it possible to cluster the <code>encrypted</code> fields together, so we achieve the following JSON?</p>
  <pre class="lang-json prettyprint-override"><code>{
    &quot;encrypted&quot;: {
      &quot;foo&quot;: &quot;foo&quot;,
      &quot;bar&quot;: &quot;bar&quot;
    }
  }
  </code></pre>