org.json.JSONException: JSONArray[0] is not a JSONObject
<p>Output of <code>String jsreturn: [{"type":1, "msg":"ERROR"}]</code>. </p>

<p>I'm trying to get the content of <code>msg</code> key which is ERROR. I'm doing that by transforming string return into an array. However I'm getting some errors commented next to each line on the follow code.
Any insight? </p>

<pre><code> Vector&lt;ClsReturn&gt; ret = null;
 ret = ds.id(collection, "fs",in_uri );

 String jsReturn = ret.toString();

 JSONObject myJsonObject = new JSONObject(ret);

 JSONArray array = new JSONArray(jsReturn); 

 int i = 0;

 while(i &lt; array.length()){
     myJsonObject = array.getJSONObject(i); //org.json.JSONException: JSONArray[0] is not a JSONObject.
     System.out.println(myJsonObject.getString("msg"));
     i++;
 }
</code></pre>