# Parsing Array in to Elasticsearch

**URL:** https://discuss.elastic.co/t/parsing-array-in-to-elasticsearch/169210
**Category:** Logstash
**Created:** [February 20, 2019, 12:46pm UTC](https://discuss.elastic.co/t/parsing-array-in-to-elasticsearch/169210 "2019-02-20T12:46:38Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Ash\_Powell](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ash_powell/32/40170_2.png) [@Ash\_Powell](https://discuss.elastic.co/u/Ash_Powell)
#### Post date: [February 20, 2019, 12:46pm UTC](https://discuss.elastic.co/t/parsing-array-in-to-elasticsearch/169210/1 "2019-02-20T12:46:39Z")

</div>

We're looking to parse an array into Elasticsearch but I'm struggling to write some Ruby code to convert it into the way that I want.

The raw data looks like this

> ```
> "marketingPreferences" => {
> "updatedDate" => "2019-02-19T22:33:17.5779143+00:00",
> "default" => [
> [0] {
> "isAllowed" => false,
> "deliveryType" => "Mail"
> },
> [1] {
> "isAllowed" => false,
> "deliveryType" => "Phone"
> },
> [2] {
> "isAllowed" => false,
> "deliveryType" => "SMS"
> },
> [3] {
> "isAllowed" => true,
> "deliveryType" => "Email"
> }
> ],
> "marketingPreferencesVersion" => "V2"
> }
> 
> ```

I would eventually like it to look like

> ```
> [marketingPreferences][Mail] => false
> [marketingPreferences][Phone] => false
> [marketingPreferences][SMS] => false
> [marketingPreferences][Email] => true
> 
> ```

etc...

Any idea on a bit of ruby code that can do this?

---

<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: [February 20, 2019, 1:17pm UTC](https://discuss.elastic.co/t/parsing-array-in-to-elasticsearch/169210/2 "2019-02-20T13:17:56Z")

</div>

Does [this](https://discuss.elastic.co/t/solved-split-filter-question-a-k-a-flatten-json-sub-array/130481/12?u=badger) help?

---

<div class="post-metadata">

### Author: ![Ash\_Powell](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ash_powell/32/40170_2.png) [@Ash\_Powell](https://discuss.elastic.co/u/Ash_Powell)
#### Post date: [February 20, 2019, 2:41pm UTC](https://discuss.elastic.co/t/parsing-array-in-to-elasticsearch/169210/3 "2019-02-20T14:41:19Z")

</div>

Amazing!

---

<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: [March 20, 2019, 2:41pm UTC](https://discuss.elastic.co/t/parsing-array-in-to-elasticsearch/169210/4 "2019-03-20T14:41:19Z")

</div>

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