Javaで残りのサービスを呼び出そうとしています。私はウェブとレストサービスが初めてです。json を応答として返す残りのサービスがあります。次のコードがありますが、json を使用して出力を処理する方法がわからないため、不完全だと思います。
public static void main(String[] args) {
try {
URL url = new URL("http://xyz.com:7000/test/db-api/processor");
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setDoOutput(true);
connection.setInstanceFollowRedirects(false);
connection.setRequestMethod("PUT");
connection.setRequestProperty("Content-Type", "application/json");
OutputStream os = connection.getOutputStream();
//how do I get json object and print it as string
os.flush();
connection.getResponseCode();
connection.disconnect();
} catch(Exception e) {
throw new RuntimeException(e);
}
}
助けてください。私は残りのサービスとjsonが初めてです。よろしくお願いします。