# How to read each array item into a map of key value pair?

**URL:** https://discuss.elastic.co/t/how-to-read-each-array-item-into-a-map-of-key-value-pair/284769
**Category:** Logstash
**Created:** [September 21, 2021, 9:31pm UTC](https://discuss.elastic.co/t/how-to-read-each-array-item-into-a-map-of-key-value-pair/284769 "2021-09-21T21:31:10Z")
**Posts on this page:** 1
**Showing post:** 2

<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: [September 21, 2021, 9:47pm UTC](https://discuss.elastic.co/t/how-to-read-each-array-item-into-a-map-of-key-value-pair/284769/2 "2021-09-21T21:47:38Z")

</div>

I would use an approach like [this](https://discuss.elastic.co/t/spliting-the-field/192191/2). Find a regexp with two capture groups, one to capture the key, one to capture the value, use .scan to get an array of arrays, then for each array use event.set to add fields to the event.

---

_[View the full topic](https://discuss.elastic.co/t/how-to-read-each-array-item-into-a-map-of-key-value-pair/284769)._
