Question: I have a JSON with lots of empty content:

```
{
    "items": [
        {
            "category": "login",
            "fields": [
                {
                    "label": "Name",
                    "value": "",
                },
                {
                    "label": "E-Mail",
                    "value": "",
                },
                {
                    "label": "Password",
                    "value": "123456",
                },
                {
                    "label": "Website",
                    "fields": [
                        {
                            "label": "Name X",
                            "value": ""
                        },
                        {
                            "label": "Name Y",
                            "value": "another one"
                        },…
                    ]
                },…
            ]
        },…
    ]
}

```

The nesting goes several levels deeper. This shows only the first level. I want to delete all elements of "fields" (or whatever the array's key in deeper levels is), where their "value" is empty.

```
{
    "items": [
        {
            "category": "login",
            "fields": [
                {
                    "label": "Password",
                    "value": "123456",
                },
                {
                    "label": "Website",
                    "fields": [
                        {
                            "label": "Name Y",
                            "value": "another one"
                        },…
                    ]
                },…
            ]
        },…
    ]
}

```

How can I do this in Javascript?

Answer: 
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.
use `filter` method,you could get a filtered array  

it returned `Boolean`. if `value` exist,it will be true

```js
var list=JSON.parse(data)
list.items=list.items.map(val=>{
  val.fields=val.fields.filter(v=>v.value})
  return val
})

```