import java.io.*; import java.net.*; import org.json.simple.*; import org.json.simple.parser.*; public class Klient2{ public static void main(String[] arg) throws Exception{ HttpURLConnection yhendus=(HttpURLConnection)new URL("https://ussouthcentral.services.azureml.net/workspaces/66e373b2084d4ffa9395c0e34ce9ccaa/services/086134d1a2fa4e7ca86c67932238b188/execute?api-version=2.0&format=swagger").openConnection(); yhendus.setDoOutput(true); yhendus.setRequestMethod("POST"); yhendus.setRequestProperty( "Content-Type", "application/json" ); yhendus.setRequestProperty("Authorization", "Bearer "+"ExuilNQzbnkIqBfzRhhd5t0N0FtFg0ioximEB2lfx+aVJck+TV3HLFplwV0/bOCiW7//6YbcVzu7onuov4oNgQ=="); String paring="{'Inputs': {'input1': [{'tollid': '2'}]}, 'GlobalParameters': {}}"; yhendus.setRequestProperty("Content-Length", ""+paring.length()); OutputStream os = yhendus.getOutputStream(); os.write(paring.getBytes()); os.flush(); os.close(); BufferedReader lugeja=new BufferedReader(new InputStreamReader(yhendus.getInputStream())); String rida=lugeja.readLine(); JSONObject jobj=(JSONObject)new JSONParser().parse(rida); System.out.println(jobj); System.out.println(jobj.get("Results")); System.out.println(((JSONObject)jobj.get("Results")).get("output1")); JSONArray jobj2=(JSONArray)((JSONObject)jobj.get("Results")).get("output1"); System.out.println(((JSONObject)jobj2.get(0)).get("cm")); } } /* [jaagup@greeny mlklient]$ javac -cp json-simple-1.1.1.jar:. Klient2.java [jaagup@greeny mlklient]$ java -cp json-simple-1.1.1.jar:. Klient2 {"Results":{"output1":[{"cm":"5.08"}]}} {"output1":[{"cm":"5.08"}]} [{"cm":"5.08"}] 5.08 [jaagup@greeny mlklient]$ */