title: Convert JSON from one format to another JSON format in java
body: <p>I have to covert a specific JSON response and covert to some other format</p>
  
  <p>For E.g. My input JSON is like </p>
  
  <p>JSON1 </p>
  
  <pre><code>[
      {
          "propertyId":10081,
          "roomId":0,
          "startDate":"2018-01-29T00:00:00",
          "endDate":"2018-01-30T00:00:00",
          "priority":1,
          "message":"Test it",
          "id":158,
          "dateModifiedUtc":null
      },
      {
          "propertyId":10081,
          "roomId":10021855,
          "startDate":"2018-01-29T00:00:00",
          "endDate":"2018-01-30T00:00:00",
          "priority":2,
          "message":"Check how it works",
          "id":159,
          "dateModifiedUtc":null
      },
      {
          "propertyId":10081,
          "roomId":10021855,
          "startDate":"2018-01-29T00:00:00",
          "endDate":"2018-01-30T00:00:00",
          "priority":2,
          "message":"Check how it works",
          "id":160,
          "dateModifiedUtc":null
      }
  ]
  </code></pre>
  
  <p>I need to replace some values for roomId and then convert json to below format and send it to some other endpoint  </p>
  
  <p>JSON2</p>
  
  <pre><code>{
      "sitenotification":[
          {
              "roomid":"10601",
              "priority":1,
              "startdate":"2017-08-10T15:50:52+03:00",
              "enddate":"2017-08-15T15:50:52+03:00",
              "sitemessage":"test"
          },
          {
              "roomid":"10601",
              "priority":1,
              "startdate":"2017-08-10T15:50:52+03:00",
              "enddate":"2017-08-15T15:50:52+03:00",
              "customermessage":"test 2"
          }
      ]
  }
  </code></pre>
  
  <p>I tried doing this in couple of ways like Deserialization using jackson and mapping it to specific class like below </p>
  
  <pre><code>@JsonIgnoreProperties(ignoreUnknown = true)
  public class FatNotificationsAttributesDataModel {
  
      @JsonProperty("propertyId")
      public int propertyId;
      @JsonProperty("roomId")
      public int roomId;
      @JsonProperty("startDate")
      public String startDate;
      @JsonProperty("endDate")
      public String endDate;
      @JsonProperty("priority")
      public int priority;
      @JsonProperty("message")
      public String message;
      @JsonProperty("id")
      public int id;
      @JsonProperty("dateModifiedUtc")
      public String dateModifiedUtc;
  
  }
  </code></pre>
  
  <p>and then again serialising it using a different class </p>
  
  <pre><code>@JsonSerialize(using = CustomSerializer.class)
  public class FinalDataModel {
  
      public int roomId;
  
      public String startDate;
  
      public String endDate;
  
      public int priority;
  
      public String message;
  
  }
  </code></pre>
  
  <p>But somehow the conversion is not working. Do we have any better way to achieve this? </p>