# Creating an array of objects

**URL:** <https://discuss.elastic.co/t/creating-an-array-of-objects/97961>\
**Category:** Logstash\
**Created:** [August 22, 2017, 7:09pm UTC](https://discuss.elastic.co/t/creating-an-array-of-objects/97961 "2017-08-22T19:09:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![AnandDivakaran](https://avatars.discourse-cdn.com/v4/letter/a/c57346/32.png) [@AnandDivakaran](https://discuss.elastic.co/u/AnandDivakaran)\
**Post date:** [August 22, 2017, 7:09pm UTC](https://discuss.elastic.co/t/creating-an-array-of-objects/97961/1 "2017-08-22T19:09:05Z")

</div>

Lets say in a given event i have 4 fields  
psn1\_name (holding the value "A",  
psn1\_age (holding the value 10,  
psn2\_name (holding the value "B",  
psn2\_age (holding the value 20.  
I want to create a field person such that person is of the following structure

person = [  
{  
"name":"A"  
,"age":10  
},  
{  
"name":"B"  
,"age":20  
}  
]

Can someone please suggest how to achieve this in the filter section of my logstash configuration.

---

<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:** [August 23, 2017, 9:26pm UTC](https://discuss.elastic.co/t/creating-an-array-of-objects/97961/2 "2017-08-23T21:26:05Z")

</div>

Hmm. I'm not entirely sure that you can do this with a mutate filter. You may have to use a ruby filter and write a line or two of Ruby code.

---

<div class="post-metadata">

**Author:** ![AnandDivakaran](https://avatars.discourse-cdn.com/v4/letter/a/c57346/32.png) [@AnandDivakaran](https://discuss.elastic.co/u/AnandDivakaran)\
**Post date:** [August 25, 2017, 3:52pm UTC](https://discuss.elastic.co/t/creating-an-array-of-objects/97961/3 "2017-08-25T15:52:11Z")

</div>

Thanks. Looks like that is the only option

---

<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:** [September 22, 2017, 3:52pm UTC](https://discuss.elastic.co/t/creating-an-array-of-objects/97961/4 "2017-09-22T15:52:18Z")

</div>

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