# Parsing json file with logstash

**URL:** <https://discuss.elastic.co/t/parsing-json-file-with-logstash/214080>\
**Category:** Logstash\
**Created:** [January 7, 2020, 3:15pm UTC](https://discuss.elastic.co/t/parsing-json-file-with-logstash/214080 "2020-01-07T15:15:23Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [January 7, 2020, 4:33pm UTC](https://discuss.elastic.co/t/parsing-json-file-with-logstash/214080/2 "2020-01-07T16:33:32Z")

</div>

> [@BeMoore](#):
>
> is their an easier way to get the json file ingested as a single document rather than lots of docs per json line ?

A json\_lines expects each line to contain an entire JSON object, so that's not going to work if your object is pretty-printed over multiple lines.

You need to use a multiline codec on the input. If you want to consume the entire file as a single event then you can use a pattern that never matches. I use

```
codec => multiline { pattern => "^Spalanzani" negate => true what => previous auto_flush_interval => 1 multiline_tag => "" }

```

If you have multiple JSON objects in a file you will need to work out the appropriate regexp for yourself.

---

_[View the full topic](https://discuss.elastic.co/t/parsing-json-file-with-logstash/214080)._
