Looks like the server is sending the escape character "\" as well all over
the place.
This one needs to be removed basically everywhere, i.e. the server should
send something like
{"User":{"id":"5", "name":"Bob" ... ... ... "FirstYear"}}
On Wednesday, December 16, 2015 at 6:11:36 PM UTC-5, Mukarram Ali wrote:
>
> 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] <javascript:>
> \",\"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/de3f08cc-b63e-4999-88da-088a0ecb986b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.