org.json.JSONException: JSONArray[0] not a string

Hi i am trying to parse json My json looks like:


i am using following code to perform action

int k=0;
for (int j = 1; j <= 7; j++)
                    String data = json.getJSONArray("data").getString(k);
                    data = data.substring(1, data.length() - 1);
                    String[] countArr = data.split(",");

Following Excetion i am geting;

org.json.JSONException: JSONArray[0] not a string.
    at org.json.JSONArray.getString(
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(
    at java.lang.reflect.Method.invoke(
    at ognl.OgnlRuntime.invokeMethod(
    at ognl.OgnlRuntime.callAppropriateMethod(
    at ognl.ObjectMethodAccessor.callMethod(


The error is quite clear. The first element is not a String but a JSONArray

Do something like this

JSONArray data = json.getJSONArray("data");

for (int i=0; i<data.length(); i++) {
    JSONArray element = data.getJSONArray(i);
    //Do something with your element

Need Your Help

Meteor publish/subscribe strategies for unique client-side collections

javascript mongodb meteor

Using Meteor, I'm wondering how best to handle different client-side collections that share the same server-side database collection. Consider the following example: I have a User collection, and ...