# Parse the json \[{},{},{}\]\[{},{},{}\] with logstash

**URL:** <https://discuss.elastic.co/t/parse-the-json-with-logstash/255642>\
**Category:** Logstash\
**Created:** [November 17, 2020, 8:48am UTC](https://discuss.elastic.co/t/parse-the-json-with-logstash/255642 "2020-11-17T08:48:48Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![thibd](https://avatars.discourse-cdn.com/v4/letter/t/7c8e57/32.png) [@thibd](https://discuss.elastic.co/u/thibd)\
**Post date:** [November 17, 2020, 8:48am UTC](https://discuss.elastic.co/t/parse-the-json-with-logstash/255642/1 "2020-11-17T08:48:48Z")

</div>

Hello,

I have a json from scrapy with this format:

```auto
[{"website1":"myurl1","importdate":"X"},{"website2":"myurl2","importdate":"X"}]
[{"website1":"myurl1","importdate":"Y"},{"website3":"myurl3","importdate":"Y"}]

```

So a new array each time when I run my script,and I would like to have the output with hits like this:  
hit1: hit1.website1 = myurl1 hit1.importdate= X  
hit2: hit2.website2 = myurl2 hit1.importdate= X  
hit3: hit3.website3 = myurl3 hit1.importdate= Y

I tried:

```auto
    input {
  file {
    path => ['/tmp/myscriptresult/*.json']
    type => "json"
    codec => "json"
  }

}

filter 
{

}

output {
	elasticsearch {
		hosts => "elasticsearch:9200"
		user => "myuser"
		password => "mypassword "
		ecs_compatibility => disabled
   	index => "cluster-%{+YYYY.MM.dd}"
    document_type => "%{[logger]}"
	}
}

```

But I have errors like

logstash\_1 | [2020-11-17T08:44:21,928][ERROR][logstash.codecs.json][main][3ef39f6257bc46c22e35cdf979584572f625dccfcd32b0b0841e54250aff99af] 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])  
logstash\_1 | at [Source: (String)"]["; line: 1, column: 2]\>, :data=\>"]["}

Do you have an idea how to do the filter ?

Thanks,

Thib

---

<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:** [December 15, 2020, 8:48am UTC](https://discuss.elastic.co/t/parse-the-json-with-logstash/255642/2 "2020-12-15T08:48:58Z")

</div>

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