# Rename recursively field names in nested structure without changing the structure

**URL:** https://discuss.elastic.co/t/rename-recursively-field-names-in-nested-structure-without-changing-the-structure/290209
**Category:** Logstash
**Created:** [November 25, 2021, 6:55pm UTC](https://discuss.elastic.co/t/rename-recursively-field-names-in-nested-structure-without-changing-the-structure/290209 "2021-11-25T18:55:51Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)
#### Post date: [November 25, 2021, 9:20pm UTC](https://discuss.elastic.co/t/rename-recursively-field-names-in-nested-structure-without-changing-the-structure/290209/2 "2021-11-25T21:20:42Z")

</div>

Not in the mood to write code on Thanksgiving, but take a look at [this](https://discuss.elastic.co/t/how-to-exclude-xml-json-key-value-if-key-length-is-greater-than-15-char-and-value-length-is-greater-than-100-char/270248/8) function. It recursively works its way through an event, including hashes and arrays, and keeps track of what the thing it is working on is called, which would allow you do something like

```
event.set("#{name}_null", event.remove(name))
```

---

_[View the full topic](https://discuss.elastic.co/t/rename-recursively-field-names-in-nested-structure-without-changing-the-structure/290209)._
