0

Below is my JSON. I need to parse the news_title in the "newsdetail" from the category list object. What is the correct way to parse this data? please help me.

 {"categorylist":[{"process":"news","ncid":"1"","newsdetail":[{"newsid":"604","category":"1","category_title":"","news_title":"just"},{"newsid":"606","category":"1","category_title":"","news_title":"fg"}]},{"process":"news","ncid":"2","newsdetail":[{"newsid":"477","category":"2","category_title":"","news_title":"way},{"newsid":"478","category":"1","category_title":"","news_title":"k"}]}
3
  • you JSON is not valid . Varify here ->jsoneditoronline.org Commented Jul 3, 2016 at 17:39
  • Did you try anything yourself for parsing this json ? Commented Jul 3, 2016 at 17:39
  • Can I have a look at your code for this issue? Commented Jul 3, 2016 at 17:54

1 Answer 1

1
{"categorylist":[{"process":"news","ncid":"1"" // cannot be double quotes come here. 
,"newsdetail":[{"newsid":"604","category":"1","category_title":"","news_title":"just"},{"newsid":"606","category":"1","category_title":"","news_title":"fg"}]},{"process":"news","ncid":"2","newsdetail":[{"newsid":"477","category":"2","category_title":"","news_title":"way},{"newsid":"478","category":"1","category_title":"","news_title":"k"}]}

you can use below parsor.. but your string data has some issue

 try {

JSONObject jsonObject = new JSONObject(data);
                    JSONArray category_list = jsonObject.getJSONArray("category_list");
                    for (int i = 0; i < category_list.length() ; i++) {
                        // here you get news title for each news
                        String newsTitle = category_list.getJSONObject(i).getString("news_title");
                    }


                }catch (JSONException e){

                }
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.