# Json array input producing \_jsonparsefailure

**URL:** https://discuss.elastic.co/t/json-array-input-producing-jsonparsefailure/140006
**Category:** Logstash
**Created:** [July 13, 2018, 7:40pm UTC](https://discuss.elastic.co/t/json-array-input-producing-jsonparsefailure/140006 "2018-07-13T19:40:41Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Scott\_Newby](https://avatars.discourse-cdn.com/v4/letter/s/eb8c5e/32.png) [@Scott\_Newby](https://discuss.elastic.co/u/Scott_Newby)
#### Post date: [July 13, 2018, 7:40pm UTC](https://discuss.elastic.co/t/json-array-input-producing-jsonparsefailure/140006/1 "2018-07-13T19:40:41Z")

</div>

We're trying to import a json file that starts as an array (starts with [and ends in].

A truncated input file:

```
[
  {
    "uri": "uri/feature",
    "id": "idvalue",
    "keyword": "Feature",
    "name": "name",
    "description": "description",
    "line": 2,
    "comments": [
      {
        "value": "#encoding: utf-8",
        "line": 1
      }
    ]
}
]

```

My ls config file:

```
input{
   file {
      path => ["path to json file"]
      start_position => "beginning"
      codec => "json"
    }
}
output{
   stdout{ codec=>"rubydebug"} 
}

```

Produces this type of error:

```
"path" => "path to json file",
          "host" => "host name",
      "@version" => "1",
       "message" => " ]\r",
    "@timestamp" => 2018-07-13T19:39:04.064Z,
          "tags" => [
        [0] "_jsonparsefailure"

```

I'm pretty sure this is related t the file starting out as an array, just trying to find out the best way to handle this situation.

---

<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: [July 13, 2018, 8:07pm UTC](https://discuss.elastic.co/t/json-array-input-producing-jsonparsefailure/140006/2 "2018-07-13T20:07:23Z")

</div>

> [@Scott\_Newby](#):
>
> "message" =\> " ]\r"

It's not related to it being an array, it's related to it consuming the file one line at a time. You should use a multiline codec on the input. In order to consume the entire file as one event I would match on a pattern that does not occur in the file.

```
codec => multiline { pattern => "Spalanzani" negate => true what => "previous" auto_flush_interval => 2 }

```

---

<div class="post-metadata">

### Author: ![Scott\_Newby](https://avatars.discourse-cdn.com/v4/letter/s/eb8c5e/32.png) [@Scott\_Newby](https://discuss.elastic.co/u/Scott_Newby)
#### Post date: [July 23, 2018, 1:42pm UTC](https://discuss.elastic.co/t/json-array-input-producing-jsonparsefailure/140006/3 "2018-07-23T13:42:36Z")

</div>

@Badger - thanks for the reply that should help us out. Appreciate it.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [August 20, 2018, 1:49pm UTC](https://discuss.elastic.co/t/json-array-input-producing-jsonparsefailure/140006/4 "2018-08-20T13:49:54Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
