title: Parse Gson with Java to get values
body: <p>I would like to get value from JSON. I am using Google Gson.</p>
  
  <p>Here is my Json format :</p>
  
  <pre><code>{
      "idContact" : 1,
      "message" : "myMessage",
      "date" : "07/03/2016 21:58:38",
      "Client" : {
          "idClient" : 122,
          "lastName" : "LASTNAME",
          "firstName" : "FIRSTNAME",
          "phone" : "060000"
      }
  }
  </code></pre>
  
  <p>I can get values from <code>message</code> and <code>date</code> by using :</p>
  
  <pre><code>Gson gson = new GsonBuilder().create();
  MyClass myClass = gson.fromJson(jsonMessage, MyClass.class);
  System.out.println("message: "+smsJson.getMessage());
  </code></pre>
  
  <p>But I can't have values for my Client. When I do <code>System.out.println("message: "+smsJson.getClient().getId());</code> I have null pointer exception.</p>
  
  <p><code>MyClass</code> is : </p>
  
  <pre><code>public class MyClass {
  String message;
  String date;
  Contact contact;
  Client client;
  }
  </code></pre>
  
  <p>Thanks</p>