V
V
Vlad Gapanovich2021-03-30 20:38:29
Java
Vlad Gapanovich, 2021-03-30 20:38:29

How to take data from apache CloseableHttpClient response?

How to take data from response? For example, I want to take titel. How can I do it? What I get by my method on the screen.

public static void main(String[] args) throws IOException {
        CloseableHttpClient httpclient = HttpClients.createDefault();
        HttpGet httpget = new HttpGet("https://videocdn.tv/api/short?api_token=92nAbf1f&id=6089");
        HttpResponse response = httpclient.execute(httpget);
        Scanner sc = new Scanner(response.getEntity().getContent());
        while(sc.hasNext()) {
            System.out.println(sc.nextLine());
        }

    }


606361f5762c9231630157.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
Orkhan, 2021-03-30
Hasanly @azerphoenix

Good afternoon!
From the response, you can see that you are getting a JSON response. Next, you need to deserialize the JSON to the pojo.
There are various libs for this. You can take Jackson or GSON.
Here is a similar question:
https://stackoverflow.com/questions/6949329/how-de...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question