Upon examining the JSON data provided, it contains a node called careerLevels which includes inner child elements.
input = {
"careerLevelGroups": [
{
"201801": 58,
"201802": 74,
"careerLevel": "Analyst",
"careerLevels": [
{
"201801": 29,
"201802": 37,
"careerID": "10000100"
},
{
"201801": 29,
"201802": 37,
"careerID": "10000110"
}
]
},
{
"201801": 58,
"201802": 74,
"careerLevel": "Consultant",
"careerLevels": [
{
"201801": 29,
"201802": 37,
"careerID": "10000080"
},
{
"201801": 29,
"201802": 37,
"careerID": "10000090"
}
]
}
]}
My goal is to programmatically remove all instances of the careerLevels node from this JSON and only retain the following information:
output= {
"careerLevelGroups": [
{
"201801": 58,
"201802": 74,
"careerLevel": "Analyst"
},
{
"201801": 58,
"201802": 74,
"careerLevel": "Consultant"
}
]}
I initially attempted to achieve this by using the code snippet below:
let strippedJson = copyObject(mergedJson);
delete strippedJson.careerLevels; // remove careerLevels but this is not doing anything.
Realizing the need for a different approach, I believe that something similar to the following pseudocode might be more suitable:
input.forEach(element => {element.delete}) // something like this