title: json: Can we avoid writing null properties while serializing objects (can we use @JsonWriteNullProperties(false) for this)?
body: <p>I'm trying to convert a json object <code>restFBResponse</code> to an object of class <code>Post</code> from Facebook graph-api.</p>
  
  <pre><code>MyPost post = gson.fromJson(restFBResponse.toString(), MyPost.class);
  </code></pre>
  
  <p>where, MyPost class is as follows:</p>
  
  <pre><code>import org.codehaus.jackson.annotate.JsonWriteNullProperties;
  
  @JsonWriteNullProperties(false)
  public class MyPost extends Post {
  
  }
  </code></pre>
  
  <p>There are many fields in <code>Post</code> class. If any of those fields (say e.g. <code>actions</code>) is absent in json object <code>restFBResponse</code> then corresponding entry in object <code>post</code> will be null. But in class <code>Post</code>, actions is assigned with an arraylist by,</p>
  
  <pre><code>List&lt;Action&gt; actions = new ArrayList&lt;Action&gt;();
  </code></pre>
  
  <p>So if <code>actions</code> is absent in <code>restFBResponse</code>, the <code>actions</code> field in <code>post</code> object will become <code>null</code>. And if I try to access actions to add new element by: </p>
  
  <pre><code>post.getActions().add(element)
  </code></pre>
  
  <p>it's resulting into error:</p>
  
  <pre><code>Exception in thread "main" java.lang.NullPointerException
  </code></pre>
  
  <p>Instead I want it to remain as <code>ArrayList&lt;Action&gt;</code> whenever <code>actions</code> is absent in <code>restFBResponse</code>. i.e. avoid writing if field is null <code>null</code>.</p>
  
  <p>How can I acheive this?</p>
  
  <p>I tried using <code>@JsonWriteNullProperties(false)</code> over all classes but still the result is same, i.e. absent elements in <code>restFBResponse</code> object have corresponding null entry in <code>post</code> object.</p>