krzyhub
krzyhub

Reputation: 6540

Getting JSON and operating on it

This is a part of my function:

public void getUrls(String category) {
    try {

        String url = "my_url"
        URL imagesJSON = new URL(url);
        HttpURLConnection conn = (HttpURLConnection) imagesJSON.openConnection();
        conn.setConnectTimeout(30000);
        conn.setReadTimeout(30000);
        conn.setInstanceFollowRedirects(true);
        InputStream is = conn.getInputStream();

        conn.disconnect();

I expect to get JSON data from a server and return it to another function. I gonna get some URLs from this JSON and return them. I am wondering which type should this function be and if I should use some function to format recieved object to operate on in properly. I will be grateful for some clues and tips.

Upvotes: 1

Views: 25

Answers (1)

Hashaŋ Sachiŋtha
Hashaŋ Sachiŋtha

Reputation: 81

Try this tutorial. Android Parsing JSON Data

Upvotes: 1

Related Questions