# Remove dynamic nested field in JSON

**URL:** <https://discuss.elastic.co/t/remove-dynamic-nested-field-in-json/152062>\
**Category:** Logstash\
**Created:** [October 11, 2018, 1:54pm UTC](https://discuss.elastic.co/t/remove-dynamic-nested-field-in-json/152062 "2018-10-11T13:54:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mahipal\_baid](https://avatars.discourse-cdn.com/v4/letter/m/c2a13f/32.png) [@mahipal\_baid](https://discuss.elastic.co/u/mahipal_baid)\
**Post date:** [October 11, 2018, 1:54pm UTC](https://discuss.elastic.co/t/remove-dynamic-nested-field-in-json/152062/1 "2018-10-11T13:54:02Z")

</div>

Hi ,

I have an input (JSON) like below:

// Sample input JSON doc

```
"TestCases": {
  "0": {
    "Verdict": "PASS",
    "tcId": 0,
    "NoOfFail": 0
  },
  "1": {
  }

```

Where number of test cases is not static and I want to remove field "NoOfFail" of each test case. I guess I cant use mutate as remove\_filed requires a static filed value.  
Can somebody help here.

Thanks,  
Mahipal

---

<div class="post-metadata">

**Author:** ![mahipal\_baid](https://avatars.discourse-cdn.com/v4/letter/m/c2a13f/32.png) [@mahipal\_baid](https://discuss.elastic.co/u/mahipal_baid)\
**Post date:** [October 12, 2018, 9:23am UTC](https://discuss.elastic.co/t/remove-dynamic-nested-field-in-json/152062/2 "2018-10-12T09:23:21Z")

</div>

I have tried many stuff including Ruby filter like below

ruby {  
code =\> "  
if event.get('[doc][ExecutionData][TestCases]') != nil  
event.set('[doc][ExecutionData][TestCases]',  
event.get('[doc][ExecutionData][TestCases]').each\_value { |url|  
event.remove(url['Verdict'])  
# event.get('[doc][ExecutionData][TestCases]').delete(url)  
# url.delete('0')  
}  
);  
end  
"  
}

But nothing works, Please help.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [November 9, 2018, 9:23am UTC](https://discuss.elastic.co/t/remove-dynamic-nested-field-in-json/152062/3 "2018-11-09T09:23:21Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
