Parsing a JSON file in Java using json-simple
<p>I have created a .json file:</p>

<pre><code>{
  "numbers": [
    {
      "natural": "10",
      "integer": "-1",
      "real": "3.14159265",
      "complex": {
        "real": 10,
        "imaginary": 2
      },
      "EOF": "yes"
    }
  ]
}
</code></pre>

<p>and I want to parse it using Json Simple, in order to extract the content of the "natural" and the "imaginary". </p>

<p>This is what I have written so far:</p>

<pre><code>JSONParser parser = new JSONParser();
Object obj = parser.parse(new FileReader("...")); //the location of the file
JSONObject jsonObject = (JSONObject) obj;
String natural = (String) jsonObject.get("natural");
System.out.println(natural);
</code></pre>

<p>The problem is that the value of natural is "null" and not "10". Same thing happens when I write jsonObject.get("imaginary").</p>

<p>I have looked at many websites (including StackOverflow), I have followed the same way most people have written, but I am unable to fix this problem.</p>