Reputation: 489
I have a JAVA for loop which prints the out put as shown below.
inside for loop::{"state":"tess","path":"/content/projectpath/en/men"} inside for loop::{"state":"hello","path":"/content/projectpath/en/women"}
Any my code snippet is as shown below.
for (Value val : values) {
//jsonobj = new JSONObject(val.getString());
out.println("inside for loop::" + val.getString());
// JSONArray jsonarr = val.getString();
}// out.println("::"+jsonobj.toString());
How to get a JSON Array after the for loop which should have the values {"state":"tess","path":"/content/projectpath/en/men"}
and {"state":"hello","path":"/content/projectpath/en/women"}
Upvotes: 1
Views: 3797
Reputation: 1956
create a JSONArray like this. insert your looping object on list. Finally you will get an array please try it.
JSONArray list = new JSONArray();
list.add(val);
Upvotes: 3