title: How to use GSON to encode String array data into JSON properly?
body: <p>I am using GSON in my Java project to encode data ( that are fetched from database and stored into a <code>String</code> array ) in <code>JSON</code> format. Everything looks OK but the problem is with the size of <code>String</code>. For example I have the following <code>String</code> array:  </p>
  
  <pre><code>String [] data = new String[12];
  </code></pre>
  
  <p>Suppose my <code>String</code> array contains the following data: <code>{"ABC", "DEF", "GH", "IJ"}</code>  </p>
  
  <p>Then the encoded JSON data are: <code>["ABC", "DEF", "GH", "IJ", "\u0000", null, null, null, null, null, null]</code>  </p>
  
  <p>The number of null value in the JSON data is depends on the number of data available in my <code>String</code> array.  </p>
  
  <p>As the data is retrieved from database so I can't declare a specific size for my <code>String</code> array.</p>
  
  <p>I am using the following code to encode <code>String</code> data into <code>JSON</code> format.  </p>
  
  <pre><code>Gson gs = new Gson();
  gs.toJson(data); //data String array contains data from database
  </code></pre>
  
  <p>Can anyone tell me how can I skip/remove those null value from my JSON data?</p>