# Flatten json array in Logstash

**URL:** <https://discuss.elastic.co/t/flatten-json-array-in-logstash/399>\
**Category:** Logstash\
**Created:** [May 8, 2015, 1:21pm UTC](https://discuss.elastic.co/t/flatten-json-array-in-logstash/399 "2015-05-08T13:21:46Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![rmoff](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rmoff/32/20212_2.png) [@rmoff](https://discuss.elastic.co/u/rmoff)\
**Post date:** [May 12, 2015, 8:40am UTC](https://discuss.elastic.co/t/flatten-json-array-in-logstash/399/4 "2015-05-12T08:40:50Z")

</div>

Thanks @jordansissel - good to know at least I'm not missing some obvious functionality 😄  
I tried your snippet (with the missing closing single quote added) with my existing simple config:

```
input {
    twitter {
        consumer_key => "foo"
        consumer_secret => "foo"
        oauth_token => "foo-foo"
        oauth_token_secret => "foo"
        keywords => ["foo","bar"]
        full_tweet => true
    }
}

filter {
          ruby {
            code => 'event["images"] = event["[entities][media]"].collect { |m| m["media_url"] }'
          }
}

output {
        elasticsearch { host => "localhost" protocol => "http" index => "twitter"}
        stdout { codec => rubydebug }
        }

```

but got an error

```
Exception in filterworker {"exception"=>#<NoMethodError: undefined method `collect' for nil:NilClass>,  

```

I'm no Ruby coder so I guess I'll have to leave this one here for now.

thanks again. Robin.

---

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