This is what I am receiving from server as a string:
{\"User\":{\"id\":\"5\",\"name\":\"Bob\",\"dob\":\"1995-12-12\",\"gender\":\"male\",\"religion\":\"hindu\",\"email\":\"[email protected]\",\"phone\":\"123456789\",\"address\":\"azadnagar\",\"classid\":\"3\",\"section\":\"A\",\"roll_no\":\"1\",\"collegeid\":\"bt123\",\"loginid\":\"junior123\",\"profilepic\":\"picsjunior123\",\"collegename\":\"FirstYear\"}}


And here is what I am doing to parse in android , sr is the received string:

JSONObject  jsonRootObject = new JSONObject(sr);
//Get the instance of JSONArray that contains JSONObjects
JSONArray jsonArray = jsonRootObject.optJSONArray("User");
String name="";
//Iterate the jsonArray and print the info of JSONObjects
for(int i=0; i < jsonArray.length(); i++){
    JSONObject jsonObject = jsonArray.getJSONObject(i);
    name = jsonObject.optString("name").toString();
     }



Exception-stack trace is in attachment.

<https://lh3.googleusercontent.com/-EPjQuFn05dc/VmyPYDlJddI/AAAAAAAAAkc/yihqsBd_9Y0/s1600/error.PNG>


-- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/android-developers/6c89bd47-95d8-4843-a99d-8adaa020f9ba%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to