移除指定位置的jsonarray

    public static JSONArray remove(int index,JSONArray jsonArray) {

        JSONArray mJsonArray = new JSONArray();

        if (index < 0){
            return mJsonArray;
        }
            
        if (index > jsonArray.length()){
            return mJsonArray;

        }
            
        for (int i = 0; i < index; i++) {
            try {
                mJsonArray.put(jsonArray.getJSONObject(i));
            } catch (JSONException e) {
                e.printStackTrace();
            }
        }

        for (int i = index + 1; i < jsonArray.length(); i++) {
            try {
                mJsonArray.put(jsonArray.getJSONObject(i));
            } catch (JSONException e) {
                e.printStackTrace();
            }
        }
        return mJsonArray;

    }
原文地址:https://www.cnblogs.com/84126858jmz/p/5152816.html