[Solved] Remove parent JSON element depending on child value


Well, I found a way to iterate through the JSON object:

function remove(jsondata) {
  for (let i in jsondata) {
    if (jsondata[i].value != undefined && jsondata[i].value == '') {
       delete jsondata[i];
    }
    else if (typeof jsondata[i] === "object") remove(jsondata[i]);
  }
}

Not sure, if it’s the most elegant way, but it works so far.

1

solved Remove parent JSON element depending on child value