Wie zu analysieren JSONObject
vom Server. Ich habe die Antwort von dem Server alsWie json Parsing in Android zu verwenden
{
"status": "success",
"authKey": "$2y$13$fg2dFdy7KbSsZP.WIddETOYxOCtJHtFwwGDTJudQ6w7hQcH5vGm16"
}
Wie zu analysieren JSONObject
vom Server. Ich habe die Antwort von dem Server alsWie json Parsing in Android zu verwenden
{
"status": "success",
"authKey": "$2y$13$fg2dFdy7KbSsZP.WIddETOYxOCtJHtFwwGDTJudQ6w7hQcH5vGm16"
}
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.
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();
}
try {
JSONObject jsonObject = new JSONObject(response.toString());
String status = jsonObject.optString("status");
String authKey = jsonObject.optString("authKey");
} catch (JSONException e) {
e.printStackTrace();
}
try {
JSONObject jsonObj =new JSONObject("your response string");
String status = jsonObj.optString("status");
String authKey = jsonObj.optString("authKey");
} catch (JSONException e) { e.printStackTrace(); }
Wie platziere ich meine Antwort-String aus der Web-Ansicht zu Code – Gopibilla
Veröffentlichen Sie den Code, den Sie versucht haben. –
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
JSONObject jsonObject = new JSONObject(response);
String status= jsonObject.getString("status");
String authKey = jsonObject.getString("authKey");
was ist die Antwortvariable hier ...? – Gopibilla
es ist Ihre Antwort Zeichenfolge. –
wie kann ? ich schließe meine Antwort hier ... – Gopibilla
Das, was Sie diese erhalten - { "Status": "Erfolg", "authkey": "2j $ 13 $ $ fg2dFdy7KbSsZP.WIddETOYxOCtJHtFwwGDTJudQ6w7hQcH5vGm16" }. ---- Ist Antwort Did verstehst du oder nicht? – Shane
danke ich werde es überprüfen – Gopibilla