title: Jackson Json Serializer to Append Inner Properties
body: <p>I am working on parsing class to JSON for <a href="https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/CreatingtheNotificationPayload.html#//apple_ref/doc/uid/TP40008194-CH10-SW1" rel="nofollow noreferrer">Apple Push Notification Service</a>. And so I have a <code>ApnsPayload</code> class and hoping to append the final JSON with the extra, optional and dynamic <code>acme</code> properties. It means I want to convert the following Jackson output...</p>
  
  <pre class="lang-json prettyprint-override"><code>{
      "aps": {
          "alert": {
              "body": "body",
              "title": "title"
          },
          "badge": 123,
          "category": "category"
      },
      "acme": {
          "1": "1",
          "value1": "value1"
      }
  }
  </code></pre>
  
  <p>To this...</p>
  
  <pre class="lang-json prettyprint-override"><code>{
      "aps": {
          "alert": {
              "body": "body",
              "title": "title"
          },
          "badge": 123,
          "category": "category"
      },
      "acme-1": "1",
      "acme-value1": "value1"
  }
  </code></pre>
  
  <p>I have successfully added a prefix <code>acme-</code> to those keys with <code>@JsonNaming()</code>, however I cannot move those properties by one level. Please help, thanks!</p>
  
  <pre class="lang-java prettyprint-override"><code>@Value
  @Builder
  @JsonInclude(JsonInclude.Include.NON_NULL)
  // need a serializer to move up properties in Acme by one level
  // @JsonSerialize(using = NewSerializer.class) 
  public class ApnsPayload {
  
      private Aps aps;
  
      private Acme acme;
  
      @JsonNaming(AcmeNamingStrategy.class) // add prefix acme-
      public interface Acme {
      }
  
      @Value
      @Builder
      @JsonInclude(JsonInclude.Include.NON_NULL)
      public static class Aps {
  
          private Alert alert;
  
          private Integer badge;
  
          private String sound;
  
          @JsonProperty("content-available")
          private Integer contentAvailable;
  
          private String category;
  
          @JsonProperty("thread-id")
          private String threadId;
  
          @Value
          @Builder
          @JsonInclude(JsonInclude.Include.NON_NULL)
          public static class Alert {
  
              private String title;
              private String body;
  
              @JsonProperty("title-loc-key")
              private String titleLocalizationKey;
  
              @JsonProperty("title-loc-args")
              private List&lt;String&gt; titleLocalizationArgs;
  
              @JsonProperty("action-loc-key")
              private String actionLocalizationKey;
  
              @JsonProperty("loc-key")
              private String localizationKey;
  
              @JsonProperty("loc-args")
              private List&lt;String&gt; localizationArgs;
  
              @JsonProperty("launch-image")
              private String launchImage;
          }
      }
  }
  </code></pre>