I want to delete all occurances of keynames like etag,formattedType and metadata in the object using dynamic iteration of whole object
 var myjson   {
        "etag": "%EiIBAgMFBgcICQoLDA0ODxATFBUWGSEiIyQlJicuNTc9Pj9AGgECIdgxQTUREdTBneFMzZz0=",
        "names": [{
            "unstructuredName": "Natalie Victor",
            "displayNameLastFirst": "Victor, Natalie",
            "familyName": "Victor",
            "displayName": "Natalie Victor",
            "givenName": "Natalie",
            "metadata": {
                "source": {
                    "id": "c8de0718a7c3458",
                    "type": "CONTACT"
                },
                "primary": true
            }
        }],
        "photos": [{
            "metadata": {
                "primary": true,
                "source": {
                    "id": "c8de0718a7c3458",
                    "type": "CONTACT"
                }
            },
            "url": "https://lh3.googleusercontent.com/-XdUIqdMkCWA/AAAAAAAAAAI/AAAAAAAAAdAA/V8BNOaftJmdYPfvspCwKr2nuTmSEuXTHowCLcDEAEiGQoBThD___________8BGKjbxPr______wE/s100/photo.jpg",
            "default": true
        }],
        "memberships": [{
            "metadata": {
                "source": {
                    "type": "CONTACT",
                    "id": "c8de0718a7c3458"
                }
            },
            "contactGroupMembership": {
                "contactGroupId": "6a68e3a408126601",
                "contactGroupResourceName": "contactGroups/6a68e3a408126601"
            }
        }, {
            "contactGroupMembership": {
                "contactGroupId": "myContacts",
                "contactGroupResourceName": "contactGroups/myContacts"
            },
            "metadata": {
                "source": {
                    "id": "c8de0718a7c3458",
                    "type": "CONTACT"
                }
            }
        }],
        "phoneNumbers": [{
            "value": "6767674765",
            "formattedType": "Home",
            "canonicalForm": "+916767674765",
            "metadata": {
                "primary": true,
                "source": {
                    "id": "c8de0718a7c3458",
                    "type": "CONTACT"
                }
            },
            "type": "home"
        }],
        "emailAddresses": [{
            "type": "home",
            "formattedType": "Home",
            "value": "nati_a_j@hotmail.com",
            "metadata": {
                "source": {
                    "id": "c8de0718a7c3458",
                    "type": "CONTACT"
                },
                "primary": true
            }
        }],
        "biographies": [{
            "contentType": "TEXT_PLAIN",
            "value": "Email: ssww@gmail.com\nName.Last: Victor\nName.First: Natalie\nPhone: 6767674765",
            "metadata": {
                "primary": true,
                "source": {
                    "id": "c8de0718a7c3458",
                    "type": "CONTACT"
                }
            }
        }],
        "resourceName": "people/c904625878430659672"
    }
I only know to use delete key by names such as
delete myjson.etag
delete myjson.names[0].metadata
How do I iterate the complete json since some of the json has arrays and nested structures which are not known in advance.
Hence a remove_keys(myjson, ["etag","memberships","formattedType","metadata"]) should render a result
var myjson   {
        "names": [{
            "unstructuredName": "Natalie Victor",
            "displayNameLastFirst": "Victor, Natalie",
            "familyName": "Victor",
            "displayName": "Natalie Victor",
            "givenName": "Natalie",
        }],
        "photos": [{
            "url": "https://lh3.googleusercontent.com/-XdUIqdMkCWA/AAAAAAAAAAI/AAAAAAAAAdAA/V8BNOaftJmdYPfvspCwKr2nuTmSEuXTHowCLcDEAEiGQoBThD___________8BGKjbxPr______wE/s100/photo.jpg",
            "default": true
        }],
        "phoneNumbers": [{
            "value": "6767674765",
            "canonicalForm": "+916767674765",
            "type": "home"
        }],
        "emailAddresses": [{
            "type": "home",
            "value": "nati_a_j@hotmail.com",
        }],
        "biographies": [{
            "contentType": "TEXT_PLAIN",
            "value": "Email: ssww@gmail.com\nName.Last: Victor\nName.First: Natalie\nPhone: 6767674765",
        }],
        "resourceName": "people/c904625878430659672"
    }
 
     
     
    