I have a class called
class Student {
String name;
String age;
}
I have a method that returns List object like
publi
You will have to include the jettison
jar in you project and import the required classes.
JSONObject jObject = new JSONObject();
try
{
JSONArray jArray = new JSONArray();
for (Student student : sudentList)
{
JSONObject studentJSON = new JSONObject();
studentJSON.put("name", student.getName());
studentJSON.put("age", student.getAge());
jArray.put(studentJSON);
}
jObject.put("StudentList", jArray);
} catch (JSONException jse) {
jse.printStacktrace();
}