-1
[{"id":0,"date":"4 - 0 - 1900","subject":"dfhjkjdfhgd","desc":"dfgbjdfiobhfh"},{"id":1,"date":"12
- 0 - 1900","subject":"4564546","desc":"fdghsdfhbrtfh"},{"id":2,"date":"6 - 0 - 1900","subject":"gfgjfcghnf","desc":"fgbnfgh"},{"id":3,"date":"11
- 0 - 1900","subject":"fgjhnfgjhnfg","desc":"fghfhn"}]

This is the string i have to parse json objects in json array.Please help me to find a solution.

Midhun
  • 178
  • 1
  • 10
  • 2
    Possible duplicate of [How to parse JSON in Android](http://stackoverflow.com/questions/9605913/how-to-parse-json-in-android) – Mike M. Oct 08 '16 at 07:59
  • your question is duplicated. see this page: http://stackoverflow.com/questions/9605913/how-to-parse-json-in-android – Amir Ziarati Oct 08 '16 at 08:09

2 Answers2

0

You can use GSON or Jackson to parse JSON array

Example:

Gson gson = new Gson(); String jsonOutput = response; Type listType = new TypeToken<List<your_POJO_class>>(){}.getType(); List<your_POJO_class> mylist = (List<your_POJO_class>)gson.fromJson(jsonOutput, listType);

okcomputer_kid
  • 491
  • 6
  • 12
0

In doInBackground

JSONArray response;    
response = new JSONArray(responseString); // responseString is your Value

String ID[];
String Date[];
String Subject[];
String Desc[];

In OnPostExecute

ID= new String[response.length()];
Date = new String[response.length()];
Subject = new String[response.length()];
Desc = new String[response.length()];
for(int i = 0 , count = response.length(); i < count ; i++ )
{
  try
  {
   JSONObject jObj = response.getJSONObject(i);
   ID[i] = jObj.getString("id");
   Date[i] = jObj.getString("date");
   Subject[i] = jObj.getString("subject");
   Desc[i] = jObj.getString("desc");
  }
  catch(JSONException e)
  {}
}
SH7
  • 732
  • 7
  • 20