I am trying to parse JSON from a URL to then add data to an array.
I am using the GSON library.
My JSON has the following format:
[
{
"img-src":"http://website.com/images/img1.png",
"URL":"http://google.com"
},
{
"img-src":"http://website.com/images/img2.jpg",
"URL":"http://yahoo.com"
}
]
I want to grab the above data in a separate thread, I have the following code:
public class Async extends AsyncTask<String, Integer, Object>{
@Override
protected String doInBackground(String... params) {
return null;
}
}
How do I go about grabbing each “img-src” and “URL” values?
Use this method to fetch your Data in an Array list
This should be how you should declare your ArrayList Type class (here its NewsItem)
Here is the WebSErvice Util Class.