I have following multi dimensional object array:
var data ='{
    "Form": [],
    "Report": [],
    "Misc": [],
    "Test5": [],
    "Test4": [],
    "Provider": [
        { "Memorial Hospital": ["img0.jpg"] },
        { "Cooper Memorial Hospital": [
            "img1.jpg",
            { "Emergency Reports": ["img2.jpg"] },
            { "Diagnostic Reports": [
                "img3.jpg",
                {
                    "12/12/2006": ["img4.jpg", "img5.jpg"],
                    "03/13/2009": ["img6.jpg", "img7.jpg"]
                }
            ]},
            { "Accident Reports": ["img8.jpg"] },
            { "Other Reports": ["img9.jpg", "img10.jpg"] }
        ]}
    ]
}';
I want to remove data from the array its img7.jpg under "03/13/2009"
What I do is:
var obj = JSON.parse(data);
console.log(obj['Provider'][1]["Cooper Memorial Hospital"][2]["Diagnostic reports"][0]["12/12/2006"]).splice(0,1);
That is all working, now issue arises when I add/remove arrays from "Cooper Memorial Hospital". Index gets recounted.
So I want to splice with out index, is there any way I can remove the img from the arrays and sub arrays just calling by img3.jpg:
removeImg("img3.jpg", obj['Provider']);
Something like this.
Update: I tried with this code, but it requires some additional code for looping through the sub arrays:
function remove(arr, what) {
    var found = arr.indexOf(what);
    while (found !== -1) {
       arr.splice(found, 1);
        found = arr.indexOf(what);
        if(found)
        break;
    }
}
remove(a,"img1");
 
    