title: Passing a DataTable object from JavaScript to Java
body: <p>I am using the Google Visualization API on the client side and I create a DataTable object. Then I want to pass it to my server and upload it via the Spreadsheet API to a spreadsheet. Probably the best way is to use JSON, so I converted it with the method toJSON() and sent it over POST to my server. I tried to use these 2 classes:</p>
  
  <ul>
  <li><a href="http://code.google.com/apis/chart/interactive/docs/reference.html#DataTable" rel="noreferrer">DataTable (JavaScript)</a></li>
  <li><a href="http://gwt-google-apis.googlecode.com/svn/javadoc/visualization/1.1/com/google/gwt/visualization/client/DataTable.html" rel="noreferrer">DataTable (Java)</a></li>
  </ul>
  
  <p>Now I noticed, that these 2 classes aren't compatible, at least not over JSON. The JavaScript class converts for example to this:</p>
  
  <pre><code>{"cols":[
           {"id":"Col1","label":"","type":"string"}
           {"id":"Col2","label":"","type":"date"}
          ],
   "rows":[
           {"c":[{"v":"a"},{"v":"Date(2010,10,6)"}]},
           {"c":[{"v":"b"},{"v":"Date(2010,10,7)"}]}
          ]
  }
  </code></pre>
  
  <p>But the Java side DataTable has different names for the parameters, and I am using Gson which has different type values:</p>
  
  <pre><code>cols -&gt; columns
  c -&gt; cells
  v -&gt; value
  
  type:"string" -&gt; type:"TEXT"
  type:"number" -&gt; type:"NUMBER"
  </code></pre>
  
  <p>And I am afraid that there are even more incompatibilities.</p>
  
  <p>So.. how can I convert the JavaScript DataTable to the Java object DataTable?</p>