# Flatten nested json array

**URL:** <https://discuss.elastic.co/t/flatten-nested-json-array/196192>\
**Category:** Logstash\
**Created:** [August 21, 2019, 9:00pm UTC](https://discuss.elastic.co/t/flatten-nested-json-array/196192 "2019-08-21T21:00:28Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![baselai](https://avatars.discourse-cdn.com/v4/letter/b/ea666f/32.png) [@baselai](https://discuss.elastic.co/u/baselai)\
**Post date:** [August 21, 2019, 9:26pm UTC](https://discuss.elastic.co/t/flatten-nested-json-array/196192/2 "2019-08-21T21:26:03Z")

</div>

Refer to this topic I created, I had a similar thing and it's solved in here

> [@Indent any json file nested fields and make it flat](https://discuss.elastic.co/t/indent-any-json-file-nested-fields-and-make-it-flat/194447/2):
>
> You will need a ruby script. Create a file called flattenJSON.rb that contains def register(params) @field = params['field'] end def flatten(object, name, event) if object if object.kind\_of?(Hash) and object != {} object.each { |k, v| flatten(v, "#{name}.#{k}", event) } else event.set(name, object) end end end def filter(event) o = event.get(@field) if o flatten(o, @field, event) end event.remove(@field) […

---

_[View the full topic](https://discuss.elastic.co/t/flatten-nested-json-array/196192)._
