S
S
Sergey Kostikov2020-08-31 14:38:15
Java
Sergey Kostikov, 2020-08-31 14:38:15

Http request on android?

I have a php server.

header("Content-Type: json/application; charset=UTF-8");
...
http_response_code(200);
echo json_encode($locations);

When I make a request via postman, the server returns a nice json.
[
    {
        "id": "1",
        "name": "Банкомат 1",
        "x": "55.9624304",
        "y": "34.0317051"
    },
    {
        "id": "2",
        "name": "Банкомат 2",
        "x": "56.9624304",
        "y": "34.0317051"
    },
    {
        "id": "3",
        "name": "Банкомат 3",
        "x": "57.9624304",
        "y": "34.0317051"
    }
]


The question is. How to implement receiving this json and processing data from it on android?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Anton Kuznetsov, 2020-08-31
@Kuznetsov

You need to use some HTTP library like Volley .
An example of a simple request to a web server: https://developer.android.com/training/volley/simple .
You can parse the received response yourself or use ready-made libraries, such as GSON .

O
Orkhan, 2020-08-31
Hasanly @azerphoenix

To deserialize Json - Gson || Jackson
For requests - okHttp

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question