# Unable to avoid JSON parsing errors in logstash log-file

**URL:** <https://discuss.elastic.co/t/unable-to-avoid-json-parsing-errors-in-logstash-log-file/84673>\
**Category:** Logstash\
**Created:** [May 5, 2017, 8:18am UTC](https://discuss.elastic.co/t/unable-to-avoid-json-parsing-errors-in-logstash-log-file/84673 "2017-05-05T08:18:16Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![guyboertje](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/guyboertje/32/31592_2.png) [@guyboertje](https://discuss.elastic.co/u/guyboertje)\
**Post date:** [May 12, 2017, 9:49am UTC](https://discuss.elastic.co/t/unable-to-avoid-json-parsing-errors-in-logstash-log-file/84673/2 "2017-05-12T09:49:44Z")

</div>

I would use the json filter instead. You should add a conditional check to see if the message field "looks" like JSON.

```auto
if [message] =~ "\A\{.+\}\z" {
  json { .. }
}

```

or similar.  
Be aware that the JSON might be an array of objects `[{},{}]`

---

_[View the full topic](https://discuss.elastic.co/t/unable-to-avoid-json-parsing-errors-in-logstash-log-file/84673)._
