title: Does Google's GSON use constructors?
body: <p>I was wondering something when working on our project. Does the GSON API from Google use the constructors from the JSON's you want to deserialize? So for example:</p>
  
  <p>I've got a JSON String which I want to convert to an Employee object. The Employee object has a constructor which applies some checks to the parameters (for example, is it's ID > 0). We're using the code below to deserialize the JSON's. But is this constructor even called when deserializing the JSON to Employee?</p>
  
  <p>Link to GSON: <a href="https://github.com/google/gson" rel="noreferrer">https://github.com/google/gson</a></p>
  
  <p><strong>EDIT:</strong>
  So after experimenting with break points I figured out the constructor is not called. Does anybody know a way to get it called anyway?</p>
  
  <pre><code>/**
   * The GSON class to help you create and de-serialize the JSON objects.
   */
  Gson gson = new Gson();
  
  /**
   * Convert JSON to an object.
   * @param json The JSON to convert.
   * @param cls The class to convert to.
   * @return The converted JSON to object.
   */
  public Object jsonToObject(String json, Class&lt;?&gt; cls) {
      return gson.fromJson(json, cls);
  }
  </code></pre>