title: How to Dynamically generate and retrieve JSON in Java code?
body: <p>I have a use case where we have to send different JSONs to different servers.</p>
  
  <p>The difference is only between JSON keys, the meaning the keys carry is same and so is the data.</p>
  
  <p>For example server XYZ wants JSON data to be sent in this format:</p>
  
  <pre><code>{ "firstName":"Sam", "lastName":"Jones"}
  </code></pre>
  
  <p>Now server ABC wants JSON data to be sent in this format:</p>
  
  <pre><code>{ "fName":"Sam", "lName":"Jones"}
  </code></pre>
  
  <p>And firstName and lastName data is populated via a POJO.</p>
  
  <p>So, How do I achieve this? I do not want to clutter the code with if-else conditions.</p>
  
  <p>But wnat to have something which would work like a template loaded dynamically and create the JSON data and also retrieve it back to the POJO.</p>