I have written a code snippet to traverse through a JSON tree and extract specific keys. However, I am facing an issue where the recursion only works once for keys labeled as "complexType" which have a tree node with additional elements. Subsequent iterations do not get called.
function retrieveKeys(json){
sequence = json["sequence"]["element"]
for(i=0;i<sequence.length;i++){
innerSequence = sequence[i]
if(innerSequence["complexType"] != undefined){
retrieveKeys(innerSequence["complexType"])
}
}
}
For the complete JSON file, you can refer to this link.