title: Android: Attempted to serialize ... Forgot to register a type adapter?"
body: <p>How to convert HashMap to JSON using <a href="https://code.google.com/p/google-gson/" rel="noreferrer">Gson</a>.</p>
  
  <pre><code>class ClassData {
      public String jsonString;
      public Class classType;
  }
  HashMap&lt;String, ClassData&gt; map = new HashMap&lt;&gt;();
  
  void convert(){
      new Gson().toJson(map); // throws
  }
  </code></pre>
  
  <p>I am getting the next exception</p>
  
  <blockquote>
    <p>Attempted to serialize java.lang.Class: java.lang.String. Forgot to
    register a type adapter?</p>
  </blockquote>