title: How to convert Map of class<T> objects to json java
body: <p>I have class with some properties, for example:</p>
  
  <pre><code>public class MyClass {
      public int number;
      public String s;
  }
  </code></pre>
  
  <p>and I want to convert Map of this class to json. for example:</p>
  
  <pre><code>Map&lt;String, MyClass&gt; map = new HashMap();
  map.put("sss", new MyClass(1, "blabla");
  
  json j = new json(map);
  </code></pre>
  
  <p>and I want the output to be like:</p>
  
  <pre><code>{"sss":{"number":"1","s":"blabla"}}
  </code></pre>
  
  <p>someone know how to do that in JAVA? I tried with <code>JSONObject</code> and with <code>Gson</code> but did not work for me.</p>