0

Here is my JSON response :

{
"Events": [
    {
        "id": 239,
        "EventTitle": "Summer Holidays",
        "EventURL": "",
        "EventURLAgency": "no",

    },

How can I get the id key in a variable ?

This is what I have tried so far :

  try {
                            JSONObject json = new JSONObject(response);
                            JSONArray jsonArray = json.getJSONArray("Events");
                            JSONObject jsonObject123 = json.getJSONObject("Events");
                            String a = jsonObject123.getString("id");
                            Log.e("HOLLA", a);
  • What you have tried? – ρяσѕρєя K Nov 29 '19 at 10:19
  • json array then json object then value for string that is id... – Shivam Oberoi Nov 29 '19 at 10:20
  • try { JSONObject json = new JSONObject(response); JSONArray jsonArray = json.getJSONArray("Events"); JSONObject jsonObject123 = json.getJSONObject("Events"); String a = jsonObject123.getString("id"); Log.e("HOLLA", a); @ShivamOberoi –  Nov 29 '19 at 10:21
  • try { JSONObject json = new JSONObject(""); JSONArray jsonArray = json.getJSONArray("Events"); for (int i = 0; i < jsonArray.length(); i++) { String id = jsonArray.getJSONObject(i).getString("id"); } } – Vishal Thakkar Nov 29 '19 at 10:32

0 Answers0