Multiple json lines in android

I need to return the entire JSON string. For example, I have one json line:

[{"Locationvalue":"Payroll - 9","LocationId":"465","IsSelected":false}] 

and also returned a second JSON string:

 [{"CC2Description":"Denver - DN","CC2":"DN","isSelected":false},{"CC2Description":"Las Vegas - LV","CC2":"LV","isSelected":false}] 

ans and so on.

In android, I wrote 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 also want to use another JSON array.

+4
source share
1 answer

You cannot decode several separate json structures in one call. The JSON structure must be a full-fledged Javascript object or array in itself, for example

Two arrays:

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

invalid because two separate arrays are split against each other. Nonetheless,

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

okay because it is the only array containing two separate child arrays. You can return several separate json strings, but they must be contained in the same structure.

+5
source

All Articles