-1

I have a result from PHP as JSONObject

{"Requests":[{"fromid":"theDude"},{"fromid":"[email protected]"}],"success":1}

I want to get the from ids intro String array in Android?. I have seen other examples but im unable to get it right.

3
  • how is the response 2D-array Commented May 21, 2014 at 7:45
  • ok i found an answer in another post here . But im unable to delete this question Commented May 21, 2014 at 7:55
  • i unmarked it and tried but it still does not work Commented May 21, 2014 at 8:51

1 Answer 1

0

Try this

String response = "{'Requests':[{'fromid':'theDude'},{'fromid':'[email protected]'}],'success':1}";
    JSONObject obj;
    try {
        obj = new JSONObject(response);
        JSONArray jarray = obj.getJSONArray("Requests");
        String success = obj.getString("success");
        if (success.equals("1")) {
            for (int i = 0; i < jarray.length(); i++) {
                JSONObject Jobj = jarray.getJSONObject(i);
                if(Jobj.has("fromid"))
                Log.i("fromid", Jobj.getString("fromid") + "fromid");

            }
        }
    } catch (JSONException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.