JSONArray array = new JSONArray(string_of_json_array);
<p>I am trying to parse Json arraylist(children) in Java using GSON and a for loop. 
But I am getting the following error:</p>

<pre><code>for each not applicable to expression type
required:array or java.lang.iterable
found:String
</code></pre>

<p>Here is the main Java Class which displays this error</p>

<pre><code> try {
     br = new BufferedReader(new FileReader("user.json"));
     Tree result = gson.fromJson(br, Tree.class);

    if (result !=null){  
      for (User t : result.getCategory()){  //ERROR IS HERE (squiggly red line)
         System.out.println(t.getId() + "-" + t.getName() + "-" + t.getCategory() + "-" + t.getPercentage());  //ERROR IS ALSO HERE FOR EACH VARIABLES
     }
    }


} catch (FileNotFoundException e) {
    e.printStackTrace();
} finally {
  if (br != null){

      try {
          br.close();
      } catch (IOException e) {
         e.printStackTrace();
      }

  }
</code></pre>

<p>This is the Tree Class:</p>

<pre><code>    private String category;
@SerializedName("children")
@Expose
private List&lt;Child&gt; children = new ArrayList&lt;Child&gt;();

public String getCategory() {
return category;
}

public void setCategory(String category) {
this.category = category;
}

public List&lt;Child&gt; getChildren() {
return children;
}

public void setChildren(List&lt;Child&gt; children) {
this.children = children;
}
</code></pre>

<p>User Class:</p>

<pre><code> private String id;
@SerializedName("processed_lang")
@Expose
private String processedLang;
@SerializedName("source")
@Expose
private String source;
@SerializedName("tree")
@Expose
private Tree tree;

public String getId() {
return id;
}

public void setId(String id) {
this.id = id;
}

public String getProcessedLang() {
return processedLang;
}

public void setProcessedLang(String processedLang) {
this.processedLang = processedLang;
}

public String getSource() {
return source;
}

public void setSource(String source) {
this.source = source;
}

public Tree getTree() {
return tree;
}

public void setTree(Tree tree) {
this.tree = tree;
}
    String getName() {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }
</code></pre>

<p>Can someone let me know where I went wrong and if you guys want to see the json code let me know I will also place it and the reason I didn't place it is because its very long.So how can I get the array list children to show? Thanks for your time.</p>