# Xml filter generates arrays with one value

**URL:** <https://discuss.elastic.co/t/xml-filter-generates-arrays-with-one-value/54314>\
**Category:** Logstash\
**Created:** [June 29, 2016, 4:16pm UTC](https://discuss.elastic.co/t/xml-filter-generates-arrays-with-one-value/54314 "2016-06-29T16:16:42Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![sagizvi](https://avatars.discourse-cdn.com/v4/letter/s/f05b48/32.png) [@sagizvi](https://discuss.elastic.co/u/sagizvi)\
**Post date:** [June 29, 2016, 4:16pm UTC](https://discuss.elastic.co/t/xml-filter-generates-arrays-with-one-value/54314/1 "2016-06-29T16:16:42Z")

</div>

Hi

I'm using an xml filter on data containing deep tags that sometimes contains arrays and sometimes dont.  
The xml filter generates the json with arrays, even when there is only one value.

> for example:  
> "Header" =\> [  
> [0] {  
> "AccountInfo" =\> [  
> [0] {  
> "CurrencyID" =\> [  
> [0] "00"  
> ],  
> "AccountID" =\> [  
> [0] "11111"  
> ]  
> }  
> ]  
> }

I'm looking for a generic way to convert all arrays with one value to a standard value.

> for example  
> "Header" =\>  
> {  
> "AccountInfo" =\>  
> {  
> "CurrencyID" =\> "00",  
> "AccountID" =\> "11111"  
> }  
> }

I'll be happy if you could help me or guide me .

Note

1. it should support deep nesting.
2. Arrays with more then one value shouldn't change.

thanks 🙂

---

<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:** [June 30, 2016, 6:43pm UTC](https://discuss.elastic.co/t/xml-filter-generates-arrays-with-one-value/54314/2 "2016-06-30T18:43:01Z")

</div>

Have a look a the [`force_array` option](https://www.elastic.co/guide/en/logstash/current/plugins-filters-xml.html#plugins-filters-xml-force_array) that was added to the xml filter rather recently.

---

<div class="post-metadata">

**Author:** ![sagizvi](https://avatars.discourse-cdn.com/v4/letter/s/f05b48/32.png) [@sagizvi](https://discuss.elastic.co/u/sagizvi)\
**Post date:** [July 1, 2016, 4:22pm UTC](https://discuss.elastic.co/t/xml-filter-generates-arrays-with-one-value/54314/3 "2016-07-01T16:22:19Z")

</div>

Hi.  
Thanks for the reply.  
It seems that it doesn't recognize this option, and i'm using version 2.3..

Sagi

---

<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:** [July 1, 2016, 5:50pm UTC](https://discuss.elastic.co/t/xml-filter-generates-arrays-with-one-value/54314/4 "2016-07-01T17:50:09Z")

</div>

You may need to upgrade the xml filter then.

---

<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:** [July 6, 2017, 4:49am UTC](https://discuss.elastic.co/t/xml-filter-generates-arrays-with-one-value/54314/5 "2017-07-06T04:49:51Z")

</div>

Closed on July 6, 2017, 4:49am UTC


