Read and analyze json data in Android and view it

advertisements

My json data looks like -

  {
   android: [
               {
                      name: "link1",
                      link: "href="/downloads/-------------""

              },
              {

                   name: "link2",
                   link: "http://www.----------"
               }
           ]
   }

I have to dispaly ONLY NAMES fetched from json data on my activity ,in such a way that when names are displayed it should be clickable and on clicking that name it should redirect it to the respective links.

**For Example : ** When NAME(link1) is fetched from json data and is clicked, it should redirect it to the respective link "href="/downloads/-----------" .

I am facing difficulty in making names clickable to their respective links.


 JsonArray root=response.getJsonArray("Android");

 for(int i=0;i<root.size();i++)
  {
  JsonObject innerElement=root.getJsonObject(i);

  String name=innerElement.getString("name");

  String name=innerElement.getString("link");
  }