How to parse JSON array from file?
<p>I have JSON from file.</p>

<pre><code>{  
  "from_excel":[  
    {  
      "solution":"Fisrt",
      "num":"1"
    },
    {  
      "solution":"Second",
      "num":"2"
    },
    {  
      "solution":"third",
      "num":"3"
    },
    {  
      "solution":"fourth",
      "num":"4"
    },
    {  
      "solution":"fifth",
      "num":"5"
    }
  ]
}
</code></pre>

<p>and want to parse list of Solution and Num.</p>

<p>Used lib <strong>org.json.simple.*</strong></p>

<p>Try this one</p>

<pre>
        Object obj = parser.parse(new FileReader("E:\\json.txt"));

        JSONObject jsonObject = (JSONObject) obj;

        out.println(jsonObject.get("from_excel"));

        JSONObject obj_new = (JSONObject) jsonObject.get("from_excel");

        JSONArray solution = (JSONArray) obj_new.get("solution");

        Iterator iterator = solution.iterator();
        while (iterator.hasNext()) {
            out.println(iterator.next());
        }
</pre>

<p>What am I doing wrong?</p>

<p>If try to write</p>

<pre>

JSONObject solutions = (JSONArray) jsonObject.get("from_excel");

</pre>

<p><a href="https://i.stack.imgur.com/dQvs5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dQvs5.png" alt="enter image description here"></a></p>

<p>If try to write </p>

<pre>

JSONArray array = obj.getJSONArray("from_excel");

</pre>

<p>get error
<a href="https://i.stack.imgur.com/0FOCP.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0FOCP.png" alt="enter image description here"></a></p>