V
V
vlarkanov2018-11-21 09:03:29
Java
vlarkanov, 2018-11-21 09:03:29

Java: how to make JSON requests to the server and how to parse responses?

Hello!
I send myself daily beautiful reports generated by a bash script pulling the Zabbix API. Because the script has long outgrown two and a half hundred lines, I wanted to port it to a high-level language. I chose Java because I study it in my spare time. I found this lib https://github.com/hengyunabc/zabbix-api , but it has a fatal flaw: it allows you to pass no more than one parameter value. Those. for example, in the filter field, you cannot pass something like

"filter": {
"value":"1",
"description":"Some kind of trigger"
}

but you can only
"filter": {
"value":"1"
}

which is not suitable for most of my tasks.
Therefore, it was decided to do something like in bash - make a post request to zabbix.server/api_jsonrpc.php and manually parse the response. What is the best way to do this?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Elmo Sputterspark, 2018-11-21
@Sputterspark

There are hundreds of libraries for this. The standard for writing REST clients and services is JAX-RS , and its reference implementation is Jersey .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question