title: Custom serialize and deserialize to create JSON
body: <p>I have a class with 2 values: val1 and val2. I am sending val1 to register (create) API and val2 is auto filled by API itself. I do not want to send val2 while calling create API and that API is not designed for handling unwanted values.</p>
  
  <p>In short I want to ignore val2 while I call create API but I want it while I call get API.</p>
  
  <p>The code that I have right now creates JSON including both the values assigning null to val2. This causes that API to throw an exception.</p>
  
  <p>Is there any easy way of doing it (java /groovy)?</p>