Parsing of Json data to get one of the fields

Use when the Json class returns an array:
Json json =new Json();
        try {
            JSONArray url = null;
            try {
                url = json.createJson();
            } catch (JSONException e) {
                e.printStackTrace ();
            }
            Log.d(TAG,url + "onCreate()");
            Log.d(TAG,"url.length() = " + url.length());
            for(int i = 0; i < url.length(); i++){//traverse JSONArray

                Log.d(TAG,"debugTest" + Integer.toString(i));
                JSONObject oj = null;
                try {
                    oj = url.getJSONObject(Integer.parseInt(String. valueOf(i)));
                    Log.d(TAG,"oj" + oj);
                } catch (JSONException e) {
                    e.printStackTrace();
                }
                int aa = 0;
                try {
                    aa = oj.getInt("url");
                    mDatas.add(aa);
                    Log.d(TAG,"aa" + aa);
                } catch (JSONException e) {
                    e.printStackTrace();
                }
                Log.d(TAG,aa + "");
            }
        }catch (Exception e){
            e.printStackTrace();
        }

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326123377&siteId=291194637