# Have Logstash take a file containing an array of JSON objects

**URL:** <https://discuss.elastic.co/t/have-logstash-take-a-file-containing-an-array-of-json-objects/150233>\
**Category:** Logstash\
**Created:** [September 27, 2018, 5:52pm UTC](https://discuss.elastic.co/t/have-logstash-take-a-file-containing-an-array-of-json-objects/150233 "2018-09-27T17:52:40Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Jedeu](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jedeu/32/35959_2.png) [@Jedeu](https://discuss.elastic.co/u/Jedeu)\
**Post date:** [September 27, 2018, 9:14pm UTC](https://discuss.elastic.co/t/have-logstash-take-a-file-containing-an-array-of-json-objects/150233/2 "2018-09-27T21:14:35Z")

</div>

All right so I managed to figure it out with Ruby, but was hoping Logstash would do more of it out of the box. For anyone else who tries to do the same thing, here's my configuration:

```
input {
  file {
    codec => multiline {
      pattern => "\]"
      negate => true
      what => next
    }
    path => "path/to/json"
    start_position => "beginning"
    sincedb_path => "dev/null"
  }
}

filter {
  ruby {
    init => "require 'json'"
    code => "real_arr = JSON.parse(event.get('message'))
             event.set('split', real_arr)
    "
  }

  split {
    field => "split"
  }

  ruby {
    code => "split = event.get('split')
             split.each do |k, val|
              event.set(k, val)
             end
    "
  }
}
```

---

_[View the full topic](https://discuss.elastic.co/t/have-logstash-take-a-file-containing-an-array-of-json-objects/150233)._
