title: Serialize List content in a flat structure in jackson json (Java)
body: <p>The class I need to Serialize:</p>
  
  <pre><code>@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
  public class MyClass {
  
      @JsonProperty("CustomerId")
      private String customerId;
  
      @JsonProperty("Products")
      private List&lt;ProductDetails&gt; products;
  
      //Getters and setters
  }
  </code></pre>
  
  <p>My ProductDetails.java class:</p>
  
  <pre><code>@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
  public class ProductDetails {
      @JsonProperty("ProductId")
      private String productId;
  
      @JsonProperty("ProductName")
      private String productName;
  
      //Getters and setters
  }
  </code></pre>
  
  <p>The default serialized output:</p>
  
  <pre><code>{
    "CustomerId" : "ewm0po",
  
    "Products" : [ {
         "ProductId" : "AAA",
         "ProductName" : "AAA Product"
       },  {
         "ProductId" : "AAA",
         "ProductName" : "AAA Product"
     }]
  }
  </code></pre>
  
  <p>The output I'm trying to get:</p>
  
  <pre><code>{
    "CustomerId" : "ewm0po",
    "ProductId1" : "AAA",
    "ProductName1" : "AAA Product"
    "ProductId2" : "AAA",
    "ProductName2" : "AAA Product"
  }
  </code></pre>
  
  <p>In other words, I am trying to skip the JSON brackets for the Products-list and suffix each of the ProductId and ProductName fields with a increasing integer.</p>
  
  <p>Any help is very much appreciated!</p>