首页 > Web开发 > 详细

移除指定位置的jsonarray

时间:2016-01-23 10:23:05      阅读:285      评论:0      收藏:0      [点我收藏+]
    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;

    }

 

移除指定位置的jsonarray

原文:http://www.cnblogs.com/84126858jmz/p/5152816.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!