title: Take advantage of JSON flexibility in Java components
body: <p>I am just trying to find a way to be more flexible.
  I have a java web-app that connects to a noSql db (couchbase). In order to map the stored jsons I have created a jar which contains all the java classes for all those jsons.</p>
  
  <p>Rex json document</p>
  
  <pre><code>{
    "age":15
  }
  </code></pre>
  
  <p>Mapping the json structure to java class:</p>
  
  <pre><code>public class Dog{
  
    private int age;
    // getters+setters
  }
  </code></pre>
  
  <p>The problem I am facing is:</p>
  
  <p>Whenever I update the db json structure (because json is flexible) I have to update also the java classes -> recompile a new jar version of the classes (and update the web-app dependency to the new jar version). </p>
  
  <p>A newly needed update for Rex json:</p>
  
  <pre><code>{
    "dob":"1999/01/25",
    "name":"Rex"
  }
  </code></pre>
  
  <p>I need an update to the Dog class looking like this:</p>
  
  <pre><code>public class Dog{
  
    private String dob;
    private String name;
    // getters+setters
  }
  </code></pre>
  
  <p>How can I create the java classes to be flexibleand to not need a new recompilation of the classes jar?
  My main objective is to not update/redeploy the web-apps connecting to noSql in case of an update of json structure.</p>
  
  <p>Hoping this is not a dumb question, I thank you,
  Georgian   </p>