# Flatten/convert Nested Array Object to string

**URL:** <https://discuss.elastic.co/t/flatten-convert-nested-array-object-to-string/151301>\
**Category:** Logstash\
**Created:** [October 6, 2018, 8:23am UTC](https://discuss.elastic.co/t/flatten-convert-nested-array-object-to-string/151301 "2018-10-06T08:23:04Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![VietCong](https://avatars.discourse-cdn.com/v4/letter/v/e47774/32.png) [@VietCong](https://discuss.elastic.co/u/VietCong)\
**Post date:** [October 6, 2018, 8:23am UTC](https://discuss.elastic.co/t/flatten-convert-nested-array-object-to-string/151301/1 "2018-10-06T08:23:04Z")

</div>

I am struggling with formatting nested array object fields where I have data structure like below:

```
"Target": [
  {
    "ID": "Unknown",
    "Type": 0
  },
  {
    "ID": "known",
    "Type": 1
  },
  {
    "ID": "Maybe",
    "Type": 2
  },
]

```

I hope to be able to get it all in one document like below:  
Target.ID0:Unknown  
Target.type0: 0  
Target.ID1:known  
Target.type1: 1  
Target.ID2:Maybe  
Target.type2: 2

Split is not a desired option since I do not want to increase the number of document. I think ruby code should be able to handle this but I have had no luck with making ruby work. Can someone please help?

Or even if I could somehow convert this to string where I can apply mutate plugins to perform some formatting, that would work as well.

---

<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:** [November 3, 2018, 8:23am UTC](https://discuss.elastic.co/t/flatten-convert-nested-array-object-to-string/151301/2 "2018-11-03T08:23:18Z")

</div>

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