create JSONArray from JSONObject
<p>Good day all</p>

<p>I am having trouble parsing a JSONArray from a JSONObject. I might just be misunderstanding.</p>

<p>Creating the JSONObject to send:</p>

<pre><code>int i = 0;
JSONArray jsonArray = new JSONArray();
String line;

while ((line = bufferedReader.readLine()) != null) {
    JSONObject rule = new JSONObject().put("rule", line);
    jsonArray.put(i,rule);
    i++;
}
return (new JSONObject().put(jsonStrings.REQUEST_RULES_ALL_RESPONSE, jsonArray));
</code></pre>

<p>This send a json array within a json object, to make things simpler. This is correct.</p>

<p>the returned object is in this format:</p>

<pre><code>{"REQUEST_RULES_ALL_RESPONSE":[ 
        {"rule":"something"},
        {"rule":"something"},
        {"rule":"something"}  ]}
</code></pre>

<p>I would like to parse this into a List RULES.
Reading the JSONObject recieved:</p>

<pre><code>//this returns the object as described above
JSONObject jsonObject = serverData.SendData(new JSONObject().put(jsonStrings.REQUEST_RULES_ALL, " ")); 

//Trying to Convert to JSONArray, the get strings are correct, 
//notice the REQUEST and REQUEST RESPONSE.

//problem line below
JSONArray JSONFirewallRules = new JSONArray ((JSONArray)jsonObject.get(jsonStrings.REQUEST_RULES_ALL_RESPONSE));  
</code></pre>

<blockquote>
  <p>ERROR: org.json.JSONException: Not a primitive array: class
  org.json.JSONArray</p>
</blockquote>

<p>I do not understand why this is a problem. I would like to get the JSONArray from the object.</p>