title: convert java object to json
body: <p>In Java I have object of this kind <code>Map&lt;Member, Map&lt;CustomerVO, Set&lt;Vehicle&gt;&gt;&gt;</code> and one other <code>List&lt;DeviceOrder&gt;</code> I wanted to convert this to json, I tried with <a href="http://code.google.com/p/google-gson/" rel="nofollow">Gson</a> but it is throwing error as <strong>"Forgot to register a type adapter?"</strong></p>
  
  <p>can someone please help how I do proceed, if not gson what would be other way to convert.</p>
  
  <p>The above error was when I tried this way </p>
  
  <pre><code>List&lt;DeviceOrder&gt; devLst;
  Gson gson = new Gson();
  String jsonStr = gson.toJson(devLst);
  </code></pre>
  
  <p>for the other one as </p>
  
  <pre><code>Map&lt;Member, Map&lt;CustomerVO, Set&lt;Vehicle&gt;&gt;&gt; map;
  Gson gson = new Gson();
  String jsonStr = gson.toJson(map);
  </code></pre>
  
  <p>Please let me know what am I doing wrong. Later I want to pass this to jsp to display.</p>
  
  <p><strong>UPDATE:</strong>
  Even tried this way as well, but no use.</p>
  
  <pre><code>Gson gson = new Gson();
  Type type = new TypeToken&lt;List&lt;DeviceOrder&gt;&gt;(){}.getType();
  String jsonstr = gson.toJson(devLst, type);
  </code></pre>