# Logstash - how to flat json array with ruby filter?

**URL:** <https://discuss.elastic.co/t/logstash-how-to-flat-json-array-with-ruby-filter/165322>\
**Category:** Logstash\
**Created:** [January 23, 2019, 2:31am UTC](https://discuss.elastic.co/t/logstash-how-to-flat-json-array-with-ruby-filter/165322 "2019-01-23T02:31:43Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![Chris\_Lyons](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/chris_lyons/32/48107_2.png) [@Chris\_Lyons](https://discuss.elastic.co/u/Chris_Lyons)\
**Post date:** [January 25, 2019, 10:45pm UTC](https://discuss.elastic.co/t/logstash-how-to-flat-json-array-with-ruby-filter/165322/4 "2019-01-25T22:45:07Z")

</div>

You can take a look at my ruby code, perhaps it will help you understand yours. Or you can just use the filter.

> [@Ruby filter for parsing deeply nested JSON in pipeline](https://discuss.elastic.co/t/ruby-filter-for-parsing-deeply-nested-json-in-pipeline/161050/4):
>
> As promised: Latest ruby filter code: [gist link](https://gist.github.com/cjlyons81/8f47a281934c8e7c040d7bf8985db331) Example pipeline usage: ruby { path =\> "/path-to-file/json-to-event.rb" script\_params =\> { "json\_field" =\> "notes" \<--Specify the field you want to extract json from (default: message) "array" =\> true \<--Do you want to flatten arrays within the json (default: false) "target" =\> "parent" \<--Specify root level name if wanted (default: root of document) "tag\_match\_failure" =\> true \<--Do you want to tag event when …

---

_[View the full topic](https://discuss.elastic.co/t/logstash-how-to-flat-json-array-with-ruby-filter/165322)._
