# Logstash unable to parse a simple json

**URL:** <https://discuss.elastic.co/t/logstash-unable-to-parse-a-simple-json/138315>\
**Category:** Logstash\
**Created:** [July 3, 2018, 6:49am UTC](https://discuss.elastic.co/t/logstash-unable-to-parse-a-simple-json/138315 "2018-07-03T06:49:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![pkaramol](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pkaramol/32/22610_2.png) [@pkaramol](https://discuss.elastic.co/u/pkaramol)\
**Post date:** [July 3, 2018, 6:49am UTC](https://discuss.elastic.co/t/logstash-unable-to-parse-a-simple-json/138315/1 "2018-07-03T06:49:39Z")

</div>

I am just trying to read the simplest `json` possible via `logstash` and send it to `elasticsearch`.

input json file:

```
{
  "preview": false
}

```

input config

input {

```
  file {
    path => "/usr/share/logstash/files/sample_data_simple.json"
    start_position => "beginning"
    codec => json
    tags => ["sometag"]
  }

```

filter config

```
filter {

}

```

output config

```
output {
  elasticsearch {
        hosts => ["elasticsearch:9200"]
        index => "someindex"
        document_type => _doc
      }
}

```

getting ...

```auto
logstash_1 | [2018-07-03T06:45:58,675][ERROR][logstash.codecs.json] JSON parse error, original data now in message field {:error=>#<LogStash::Json::ParserError: Unexpected end-of-input: expected close marker for Object (start marker at [Source: (String)"{"; line: 1, column: 1])
logstash_1 | at [Source: (String)"{"; line: 1, column: 3]>, :data=>"{"}
logstash_1 | [2018-07-03T06:45:58,754][ERROR][logstash.codecs.json] JSON parse error, original data now in message field {:error=>#<LogStash::Json::ParserError: incompatible json object type=java.lang.String , only hash map or arrays are supported>, :data=>" \"preview\": false"}
logstash_1 | [2018-07-03T06:45:58,757][ERROR][logstash.codecs.json] JSON parse error, original data now in message field {:error=>#<LogStash::Json::ParserError: Unexpected close marker '}': expected ']' (for root starting at [Source: (String)"}"; line: 1, column: 0])

```

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [July 3, 2018, 7:22am UTC](https://discuss.elastic.co/t/logstash-unable-to-parse-a-simple-json/138315/2 "2018-07-03T07:22:24Z")

</div>

The file input reads files line by line. If you want to read the whole file into a single Logstash event you need to use a multiline codec. Examples of this have been posted in the past.

---

<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:** [July 31, 2018, 7:22am UTC](https://discuss.elastic.co/t/logstash-unable-to-parse-a-simple-json/138315/3 "2018-07-31T07:22:25Z")

</div>

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