title: JSON performance
body: <p>I have to turn a <code>List&lt;Map&gt;</code> into a JSON string. The <code>Map</code>s are flat and containing primitive and String data. Right now I'm using GSON. Basically like this:</p>
  
  <pre><code>List&lt;Map&gt; list = new ArrayList();
  
  Map map = new HashMap();
  map.put("id",100);
  map.put("name","Joe");
  map.put("country","US");
  // ...
  list.add(map);
  
  Gson gson = new GsonBuilder().disableHtmlEscaping().setPrettyPrinting().create(); 
  Stopwatch sw = Stopwatch.createStarted(); // guava's stopwatch 
  String s = gson.toJson(list);
  System.err.println("toJson laps " + sw);
  return s;
  </code></pre>
  
  <p>The <code>list</code> may have 100 entries and each map aprox. 20 fields. GSON really takes long time to create the JSON string. The JSON string will be returned by a HTTP response and right now it took too much time (8000ms). So I try other ones: json-smart, jackson, etc. But no one gives a significant speed boost. I trace the JSON string creation as the hot spot in execution time.</p>
  
  <p>For 100 x 20 fields I really won't expect more than a second but it takes significant much more time. Is there any heal for this ?</p>
  
  <p><strong>Update</strong>
  I have overseen some BLOB data that is returned. Thank you all.</p>