Analysieren Sie JSON anhand des HttpURLConnection-Objekts

Ich mache grundlegende http auth mit derHttpURLConnection Objekt in Java.

<code>        URL urlUse = new URL(url);
        HttpURLConnection conn = null;
        conn = (HttpURLConnection) urlUse.openConnection();
        conn.setRequestMethod("GET");
        conn.setRequestProperty("Content-length", "0");
        conn.setUseCaches(false);
        conn.setAllowUserInteraction(false);
        conn.setConnectTimeout(timeout);
        conn.setReadTimeout(timeout);
        conn.connect();

        if(conn.getResponseCode()==201 || conn.getResponseCode()==200)
        {
            success = true;
        }
</code>

Ich erwarte ein JSON-Objekt oder Zeichenfolgendaten im Format eines gültigen JSON-Objekts oder HTML mit einfachem Nur-Text, der für JSON gültig ist. Wie greife ich auf das von derHttpURLConnection nachdem es eine Antwort zurückgibt?

Antworten auf die Frage(5)

Ihre Antwort auf die Frage