Made a request to the server. It returns the answer:

{ "response": { "count": 462409, "items": [ { "message": { "id": 552885, "date": 1376054836, "out": 0, "user_id": 185014513, "read_state": 0, "title": " ... ", "body": "test" } } ] } } 

Using this code, I get to message and write the contents to the arraylist:

  try { JSONObject jsonObject = (JSONObject) response.json.get("response"); JSONArray jsonArray = (JSONArray) jsonObject.get("items"); for (int i = 0; i<jsonArray.length();i++){ JSONObject name = (JSONObject) jsonArray.get(i); arrayList.add(name.getString("message")); 

How can I refer to the title contained within the message and write its contents to arrayList? Thank.

    2 answers 2

     for (int i = 0; i<jsonArray.length();i++){ JSONObject name = (JSONObject) jsonArray.get(i); JSONObject message = (JSONObject) jsonArray.get(i).get("message"); arrayList.add(message.get("title")); } 
    • Pavel, can I get in touch with you somehow? I want to ask a question. - Donald Rump

    Json parsing Android Java Here is pretty well described how to access the necessary elements of the json object. Well, write to ArrayList is no longer a problem. In your case, this is items -> message -> title