Retrieving JSON from URL on Android

前端 未结 6 1824
无人共我
无人共我 2020-12-03 12:56

My phone APP downloads content perfectly in a text mode. Below is a code to do that. I call Communicator class and exectueHttpGet:

URL_Data = new Communicator(

6条回答
  •  孤城傲影
    2020-12-03 13:14

    use org.json.JSONObject as in

    JSONObject json = new JSONObject(oage);
    

    thing to watch out for is when the response is simply "true" or "false." probably want to create a util function that checks for those cases, otherwise just load up the JSONObject.

    ok in this case you would use a JSONArray

    JSONArray jsonArray = new JSONArray(page); 
    for (int i = 0; i < jsonArray.length(); ++i) {
      JSONObject element = jsonArray.getJSONObject(i);
      ..... 
    }
    

提交回复
热议问题