-4

look bellow

{
    "count": 1,
    "next": null,
    "previous": null,
    "results": [
        {
            "customMetaTags": [
                {
                    "metatag": "#TAPE"
                }
            ],
            "geoPolitical": [
                {
                    "gp_code": "Default  / All GPIDs"
                }
            ],
            "entity": [],
            "topics": [
                {
                    "topic_code": "#CAR"
                },
                {
                    "topic_code": "#CAREER"
                },
                {
                    "topic_code": "#CAREERS"
                },
                {
                    "topic_code": "#CARE"
                }
            ]
        }
    ]
}
ArunPratap
  • 4,816
  • 7
  • 25
  • 43
  • Try this tutorial [Here](https://androidbeasts.wordpress.com/2015/08/04/json-parsing-tutorial/) – Sniffer Sep 10 '18 at 04:56
  • i have crated serialzable class of each object and from that i have to read topic value public class Topic implements Serializable { @SerializedName("topic_code") @Expose private String topicCode; private final static long serialVersionUID = 6882971486454840638L; public String getTopicCode() { return topicCode; } public void setTopicCode(String topicCode) { this.topicCode = topicCode; } } – PURUSHOTTAM KUMAR Sep 10 '18 at 05:29
  • how to read topics value and set in textview – PURUSHOTTAM KUMAR Sep 10 '18 at 05:30

1 Answers1

0

Please try this

try {
                ArrayList<String> topicsList = new ArrayList<>();
                JSONObject jsonObject = new JSONObject(resultJSON);
                JSONArray result = jsonObject.getJSONArray("results");
                for(int i=0;i<result.length();i++) {
                    JSONObject jsonObject1 = result.getJSONObject(i);
                    JSONArray topics = jsonObject1.getJSONArray("topics");
                    for(int j=0;j<topics.length();j++) {
                        JSONObject jsonObject11 = topics.getJSONObject(j);
                        topicsList.add(jsonObject11.getString("topic_code"));
                    }
                }
            } catch (JSONException e) {
                e.printStackTrace();
            }
Saurabh Vadhva
  • 511
  • 5
  • 12