0

I am developing an android application in which i have to parse the url in json format.Url is

http://search.yahooapis.com/NewsSearchService/V1/newsSearch?appid=YahooDemo&output=json

I have tried by making json format object and then passing values.Has anyone implemented it before,If yes can he help me?

Thanks in advance Tushar

0

2 Answers 2

1

catch the "Error" element like JSONObject, not JSONArray.

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

4 Comments

,,,,, now i am getting error unable to load page http bad request
i have pasted my full code in my answer,Check and reply..waiting for ur response
i can not see any code in your answer. I only see the JSON URL and the error.
its full code run it and revert me back,,waiting for ur response,,,,,pastebin.com/cWzWD4cj
0

You can use GSON. Take a look at this article. You parse it like this:

public void runJSONParser(){
        try{
        Log.i("MY INFO", "Json Parser started..");
        Gson gson = new Gson();
        Reader r = new InputStreamReader(getJSONData("http://search.twitter.com/trends.json"));
        Log.i("MY INFO", r.toString());
        TwitterTrends objs = gson.fromJson(r, TwitterTrends.class);
        Log.i("MY INFO", ""+objs.getTrends().size());
        for(TwitterTrend tr : objs.getTrends()){
            Log.i("TRENDS", tr.getName() + " - " + tr.getUrl());
        }
        }catch(Exception ex){
            ex.printStackTrace();
        }
    }

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.