How do I recursively find key name in nested objects that contain an empty object?
<p>I initially receive a response of</p>

<pre><code>var o={
    "StudentInfo": [{
        "Name1": [{
            "100": {
                "a": "12"
            }
        }, {
            "101": {
                "a": "50"
            }
        }]
    }, {
        "Name2": [{
            "102": {}
        }, {
            "103": {
                "b": "50"
            }
        }]
    }]
}
</code></pre>

<p>I have a JSON objects, after some operations, objects is empty(like empty objects 102), I want to print it and parent objects names (like "Name2").</p>

<p>I tried this,</p>

<pre><code>    var emptyKeys = [];
    var FLAG=false;

    function emptyObjToNull(object,keysArr){
        var isObject, hasKeys, isArray, current;
        for(var k in object){
            if(!object.hasOwnProperty(k))
                return;
            current = object[k];
            console.log("current KK "+k);
             console.log(current);

            isObject = typeof current == 'object';
            hasKeys = isObject &amp;&amp; Object.keys(current).length !== 0;
            if(hasKeys){
                emptyObjToNull(current, keysArr);
            }else if(isObject &amp;&amp; !hasKeys){
               //object[k] = null; // Set the key directly, not the reference
               FLAG=true;
               keysArr.push(k);
            }
        }
    }

emptyObjToNull(o,emptyKeys);

console.log(emptyKeys);
</code></pre>