remove object from json array javascript code example
Example 1: javascript remove json element
jsonArray.splice(2, 1)
meaning : delete 1 item at position 3 ( because array is counted form 0, then item at no 3 is counted as no 2 )
Example 2: delete value from json array with index
ArrayList<String> list = new ArrayList<String>();
JSONArray jsonArray = (JSONArray)jsonObject;
int len = jsonArray.length();
if (jsonArray != null) {
for (int i=0;i<len;i++){
list.add(jsonArray.get(i).toString());
}
}
list.remove(position);
JSONArray jsArray = new JSONArray(list);