2016-12-27 15 views

Antwort

-1

Hier Lösung ist

try{ 
    JSONObject object = new JSONObject(response) 
    String status = oject.getString("status") 
    String authKey = oject.getString("authKey") 
}catch(Exception e){ e.printStackTrace();} 

es Hoffnung wird Ihnen helfen.

+0

wie kann ? ich schließe meine Antwort hier ... – Gopibilla

+0

Das, was Sie diese erhalten - { "Status": "Erfolg", "authkey": "2j $ 13 $ $ fg2dFdy7KbSsZP.WIddETOYxOCtJHtFwwGDTJudQ6w7hQcH5vGm16" }. ---- Ist Antwort Did verstehst du oder nicht? – Shane

+0

danke ich werde es überprüfen – Gopibilla

1

A JSON Objekt Schlüssel/Wert-Paare wie Karte enthält. Die Schlüssel sind Strings und die Werte sind die JSON-Typen. Schlüssel und Werte sind durch Komma getrennt.

Sie können mit dieser Art und Weise versuchen

   String getStatus = "",authKey=""; 
      try { 
       JSONObject reader = new JSONObject("{"status":"success","authKey":"$2y$13$fg2dFdy7KbSsZP.WIddETOYxOCtJHtFwwGDTJudQ6w7hQcH5vGm16"}"); //Put your Json String 
       getStatus = reader.getString("status"); 
       authKey = reader.getString("authKey"); 
       } 
       catch (JSONException e) { 
       e.printStackTrace(); 
      } 
+0

wie bekomme ich die JSON-String in den "Your_Json" Ort – Gopibilla

+0

@Gopibilla bitte Ihre Arbeit zeigen. –

+0

http://amogaa.com/nimaatri/frontend/web/?r=site/cust-login&username=mohan&password=Test1234 – Gopibilla

0
try { 
    JSONObject jsonObject = new JSONObject(response.toString()); 

    String status = jsonObject.optString("status"); 
    String authKey = jsonObject.optString("authKey"); 
} catch (JSONException e) { 
    e.printStackTrace(); 
} 
0
try { 
    JSONObject jsonObj =new JSONObject("your response string"); 
    String status = jsonObj.optString("status"); 
    String authKey = jsonObj.optString("authKey"); 
} catch (JSONException e) { e.printStackTrace(); } 
+0

Wie platziere ich meine Antwort-String aus der Web-Ansicht zu Code – Gopibilla

+0

Veröffentlichen Sie den Code, den Sie versucht haben. –

+0

http://amogaa.com/nimaatri/frontend/web/?r=site/cust-login&username=mohan&password=Test1234 dies ist der link und ich möchte den authkey von diesem link wie bekomme ich es – Gopibilla

-1
JSONObject jsonObject = new JSONObject(response); 
String status= jsonObject.getString("status"); 
String authKey = jsonObject.getString("authKey"); 
+0

was ist die Antwortvariable hier ...? – Gopibilla

+0

es ist Ihre Antwort Zeichenfolge. –