Regarding question Android (JSONObject) How can I loop through a flat JSON object to get each key and each value, I am using Franci Penov's answer to perform an iteration through the items of my JSON.
My problem is, when I find what I want, then I want to delete it. But how do I know if I am deleting the correct JSON Key if there maybe more than one item with same ID in a nested JSON object?
There is my code:
public JSONObject parseJSON(JSONObject json)
{
    Iterator<String> iter = json.keys();
    while (iter.hasNext())
    {
        String key = iter.next();
        if (key.equals("-xmlns:i") ||
            key.equals("-i:nil") ||
            key.equals("-xmlns:d4p1") ||
            key.equals("-i:type") ||
            key.equals("#text")) // I want to delete items with those ID strings
        {
            json.remove(key);
        }
        //Object value = json.get(key);
    }
    return json;
}