# Parse array of json objects in json

**URL:** https://discuss.elastic.co/t/parse-array-of-json-objects-in-json/106518
**Category:** Logstash
**Created:** [November 6, 2017, 11:51am UTC](https://discuss.elastic.co/t/parse-array-of-json-objects-in-json/106518 "2017-11-06T11:51:29Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![mPanasiewicz](https://avatars.discourse-cdn.com/v4/letter/m/ebca7d/32.png) [@mPanasiewicz](https://discuss.elastic.co/u/mPanasiewicz)
#### Post date: [November 6, 2017, 11:51am UTC](https://discuss.elastic.co/t/parse-array-of-json-objects-in-json/106518/1 "2017-11-06T11:51:29Z")

</div>

Hello,  
I've got sth like:

```auto
[
{"aaa": "bbb"},
{"ccc": "ddd"},
{"eee": "fff"}
] 

```

I've tried split input plugin but I think it would not work becouse I need parent key of the array. In this case there is no key because array is top instance without key. I read this:

> [@Parsing a JSON array of objects](https://discuss.elastic.co/t/parsing-a-json-array-of-objects/55441):
>
> I have a log file that's an array of objects that looks something like this: [{ "cate1": "data1a", "cate2": "data2a" }, { "cate1": "data1b", "cate2": "data2b" }] and I need each object in the array to be a separate entry in Elasticsearch and each "cate" to be a field. How would I go about configuring Logstash to do this?

but there is no answer of my problem.  
Thank you for your help.

---

<div class="post-metadata">

### Author: ![paz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/paz/32/28003_2.png) [@paz](https://discuss.elastic.co/u/paz)
#### Post date: [November 6, 2017, 2:23pm UTC](https://discuss.elastic.co/t/parse-array-of-json-objects-in-json/106518/2 "2017-11-06T14:23:03Z")

</div>

What exactly is your goal? Do you need each element as a separate event or as a top-level field in the same event?

Also, what is the actual input?

---

<div class="post-metadata">

### Author: ![mPanasiewicz](https://avatars.discourse-cdn.com/v4/letter/m/ebca7d/32.png) [@mPanasiewicz](https://discuss.elastic.co/u/mPanasiewicz)
#### Post date: [November 6, 2017, 2:39pm UTC](https://discuss.elastic.co/t/parse-array-of-json-objects-in-json/106518/3 "2017-11-06T14:39:15Z")

</div>

My input is sth like this:

```auto
[
{"aaa": "bbb"},
{"ccc": "ddd"},
{"eee": "fff"}
] 

```

I would like each object separate as a document.  
Document:  
`{"aaa": "bbb"}`  
Document:  
`{"ccc": "ddd"}`  
Document:  
`{"eee": "fff"}`

---

<div class="post-metadata">

### Author: ![paz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/paz/32/28003_2.png) [@paz](https://discuss.elastic.co/u/paz)
#### Post date: [November 6, 2017, 2:49pm UTC](https://discuss.elastic.co/t/parse-array-of-json-objects-in-json/106518/4 "2017-11-06T14:49:08Z")

</div>

Then defining a

```auto
codec => "json"
```

in your input should be sufficient enough for this (unless it's multiline, in which case it becomes a bit trickier).

---

<div class="post-metadata">

### Author: ![mPanasiewicz](https://avatars.discourse-cdn.com/v4/letter/m/ebca7d/32.png) [@mPanasiewicz](https://discuss.elastic.co/u/mPanasiewicz)
#### Post date: [November 6, 2017, 3:34pm UTC](https://discuss.elastic.co/t/parse-array-of-json-objects-in-json/106518/5 "2017-11-06T15:34:15Z")

</div>

@Paris Mermigkas It's working!!! Thank you very much. I thought that I need to do this by filter but codec works great! Thank you!!!

Topic can be closed

---

<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 4, 2017, 3:34pm UTC](https://discuss.elastic.co/t/parse-array-of-json-objects-in-json/106518/6 "2017-12-04T15:34:29Z")

</div>

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