# Partially flatten json structure in logstash filter

**URL:** <https://discuss.elastic.co/t/partially-flatten-json-structure-in-logstash-filter/150173>\
**Category:** Logstash\
**Created:** [September 27, 2018, 10:28am UTC](https://discuss.elastic.co/t/partially-flatten-json-structure-in-logstash-filter/150173 "2018-09-27T10:28:09Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![johnjingle](https://avatars.discourse-cdn.com/v4/letter/j/87869e/32.png) [@johnjingle](https://discuss.elastic.co/u/johnjingle)\
**Post date:** [September 27, 2018, 10:28am UTC](https://discuss.elastic.co/t/partially-flatten-json-structure-in-logstash-filter/150173/1 "2018-09-27T10:28:09Z")

</div>

Hi,

We have

{  
"recordA": {  
"recordB": {  
"someField1" : "john"  
"somefield2": "smith"  
}  
}  
}  
and wish to move the fields up one level so recordB disappears and the fields are directly under recordA.

{  
"recordA": {  
"someField1" : "john"  
"somefield2": "smith"  
}  
}

Can you help please?

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [September 27, 2018, 11:12am UTC](https://discuss.elastic.co/t/partially-flatten-json-structure-in-logstash-filter/150173/2 "2018-09-27T11:12:40Z")

</div>

Use a mutate filter and its rename option.

---

<div class="post-metadata">

**Author:** ![johnjingle](https://avatars.discourse-cdn.com/v4/letter/j/87869e/32.png) [@johnjingle](https://discuss.elastic.co/u/johnjingle)\
**Post date:** [September 27, 2018, 1:29pm UTC](https://discuss.elastic.co/t/partially-flatten-json-structure-in-logstash-filter/150173/3 "2018-09-27T13:29:24Z")

</div>

Thanks.

```
{
"recordA": {
            "recordB": {
                       "someField1" : "john"
                       "somefield2": "smith"
                  }
           }
}

```

I cannot figure out the syntax for the rename and have not succeeded finding online.  
Somehow I need to access [recordA][recordB][somefield1] and make it [recordA][somefield1]

---

<div class="post-metadata">

**Author:** ![johnjingle](https://avatars.discourse-cdn.com/v4/letter/j/87869e/32.png) [@johnjingle](https://discuss.elastic.co/u/johnjingle)\
**Post date:** [September 27, 2018, 2:16pm UTC](https://discuss.elastic.co/t/partially-flatten-json-structure-in-logstash-filter/150173/4 "2018-09-27T14:16:48Z")

</div>

Thanks got working.

---

<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:** [October 25, 2018, 2:28pm UTC](https://discuss.elastic.co/t/partially-flatten-json-structure-in-logstash-filter/150173/5 "2018-10-25T14:28:52Z")

</div>

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