2016-03-28 1 views
-3
returnLogin([{ 
    "id": 0, 
    "first_name": "abc", 
    "last_name": "xyz", 
    "msg": "Invalid User or Location ID or Password.", 
    "location_id": "", 
}]) 

Comment obtenir les données de la chaîne Json ci-dessus? ici json commencer avec witn chaîne pas de support c'est pourquoi je tente de. obtenir des donnéesandroid json à partir de la chaîne

+0

Avez-vous même essayé? Afficher votre code –

+0

try { JSONObject jsonObject = new JSONObject (response); System.out.println ("jsonResponse" + jsonObject); } catch (JSONException e) { e.printStackTrace(); } – Manish

Répondre

0

vous pouvez analyser comme ci-dessous,

String data = "";// here your json data which will parse 
     try { 
      JSONArray jsonArray = new JSONArray(data); 
      JSONObject jsonObject=jsonArray.getJSONObject(0); 
      int id=jsonObject.getInt("id"); 
      String first_name=jsonObject.getString("first_name"); 
      String last_name=jsonObject.getString("last_name"); 
      String msg=jsonObject.getString("msg"); 
      String location_id=jsonObject.getString("location_id"); 
     } catch (JSONException e) { 
      e.printStackTrace(); 
     } 

Mais avant Parse corriger vos données.

+0

son cours pour JSONexception :: org.json.JSONException: Valeur returnLogin (de type java.lang.String ne peut pas être converti en JSONArray – Manish

+0

Parce que vos données a eu tort s'il vous plaît corriger, mettre vos –

+0

s'il vous plaît données JSON originales, –