multiple json string in android

android

Solution

You cannot decode multiple separate json structures in a single call. A JSON structure must be a complete proper Javascript object or array on its own, e.g.

Two arrays like this:

[1,2,3][4,5,6]

is invalid, because it's two separate arrays smashed up against each other. However,

[[1,2,3],[4,5,6]]

is ok, because it's a single array that contains two separate child arrays. You can return multiple separate json strings, but they must be contained within a single structure.

Problem

I have to return all my JSON string. For example I have one json string: ``` [{"Locationvalue":"Payroll - 9","LocationId":"465","IsSelected":false}] ``` and also returned second JSON string: ``` [{"CC2Description":"Denver - DN","CC2":"DN","isSelected":false},{"CC2Description":"Las Vegas - LV","CC2":"LV","isSelected":false}] ``` ans so on. In android I have written this: ``` JSONArray JsonObject = new JSONArray(JsonString.toString()); for(int i=0;i<JsonObject.length();i++) { Log.v("log", JsonObject.getString(i)); } ``` but I can only access one JSON array. I want other JSON array also.

Original source