title: Store JSON data in Java
body: <p>I want to learn JSON data storage in Java using Eclipse, so I googled a lot.</p>
  <p>I found <a href="https://code.google.com/p/json-simple/" rel="nofollow noreferrer">JSON.simple</a> and <a href="https://code.google.com/p/google-gson/" rel="nofollow noreferrer">GSON</a>. Are those a good choice?</p>
  <p>I went to <code>Properties &gt;&gt; Java Build Path &gt;&gt; Add External JARs</code>. I added <a href="https://code.google.com/p/json-simple/downloads/detail?name=json-simple-1.1.1.jar" rel="nofollow noreferrer">json-simple-1.1.1.jar</a> and <a href="https://code.google.com/p/google-gson/downloads/detail?name=google-gson-2.2.4-release.zip&amp;can=2&amp;q=" rel="nofollow noreferrer">google-gson-2.2.4-release.zip</a>. Is it right? Where is the JavaDoc located?</p>
  <p>Main problem concerns an example found here: <a href="http://www.mkyong.com/java/json-simple-example-read-and-write-json/" rel="nofollow noreferrer">JSON.simple example – Read and write JSON</a>, which teaches about JSON.simple.
  I wrote the following code:</p>
  <pre><code>JSONObject object = new JSONObject();
  JSONArray array = new JSONArray();
  array.add(&quot;Bob&quot;);
  array.add(&quot;John&quot;);
  object.put(&quot;nicknames&quot;, array);
  object.put(&quot;from&quot;, &quot;US&quot;);
  object.put(&quot;age&quot;, 35);
  try {
      String path = &quot;&quot;;
      FileWriter file = new FileWriter(path);
      String json = object.toJSONString();
      file.write(json);
      file.close();
  } catch (IOException io) {
      // Fail
  }
  </code></pre>
  <p>But I get the following warnings. What do these mean?</p>
  <blockquote>
  <p>Type safety: The method add(Object) belongs to the raw type ArrayList. References to generic type ArrayList should be parameterized on 'JSONArray.add'</p>
  </blockquote>
  <blockquote>
  <p>Type safety: The method put(Object, Object) belongs to the raw type HashMap. References to generic type HashMap&lt;K,V&gt; should be parameterized on 'JSONObject.put'</p>
  </blockquote>
  <p>On a side note, how can I prettify my JSON?</p>