# How to do split into array of object

**URL:** https://discuss.elastic.co/t/how-to-do-split-into-array-of-object/192811
**Category:** Logstash
**Created:** [July 30, 2019, 3:08am UTC](https://discuss.elastic.co/t/how-to-do-split-into-array-of-object/192811 "2019-07-30T03:08:04Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![mrjayarajj](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mrjayarajj/32/51188_2.png) [@mrjayarajj](https://discuss.elastic.co/u/mrjayarajj)
#### Post date: [July 30, 2019, 3:08am UTC](https://discuss.elastic.co/t/how-to-do-split-into-array-of-object/192811/1 "2019-07-30T03:08:04Z")

</div>

i am new to logstash

my SQL output is like below

FIRSTNAME-----LASTNAME----------PERMISSIONS  
jayaraj------------jaganathan----------BLK\_RTE\_APPRV,PLACE\_GPO,ORD\_AUTH

i need to convert into

{  
"firstName" : "Jayaraj",  
"lastName" : "Jaganathan",  
"permissionList" : [  
{ "name" : "BLK\_RTE\_APPRV" } ,  
{ "name" : "PLACE\_GPO" } ,  
{ "name" : "ORD\_AUTH" }  
]  
}

i tried multiple options, i din't get desired out put

my .conf look like below

mutate {  
split =\> {"permissions" =\> ","}  
rename =\> {  
"firstname" =\> "firstName"  
"lastname" =\> "lastName"  
}  
}

need help`Preformatted text`

---

<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 30, 2019, 1:07pm UTC](https://discuss.elastic.co/t/how-to-do-split-into-array-of-object/192811/2 "2019-07-30T13:07:50Z")

</div>

mutate+split will get you

```
"permissions" => [
    [0] "BLK_RTE_APPRV",
    [1] "PLACE_GPO",
    [2] "ORD_AUTH"
],

```

You will have to use ruby to get the format you want.

```
    ruby {
        code => '
            a = []
            event.get("permissions").each { |x|
                a << { "name" => x }
            }
            event.set("permissionsList", a)
        '
    }
```

---

<div class="post-metadata">

### Author: ![mrjayarajj](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mrjayarajj/32/51188_2.png) [@mrjayarajj](https://discuss.elastic.co/u/mrjayarajj)
#### Post date: [July 30, 2019, 2:48pm UTC](https://discuss.elastic.co/t/how-to-do-split-into-array-of-object/192811/3 "2019-07-30T14:48:21Z")

</div>

It works , thanks a lot

---

<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 27, 2019, 2:48pm UTC](https://discuss.elastic.co/t/how-to-do-split-into-array-of-object/192811/4 "2019-08-27T14:48:24Z")

</div>

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