Xml filter generates arrays with one value

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 :slight_smile:

Have a look a the force_array option that was added to the xml filter rather recently.

1 Like

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

Sagi

You may need to upgrade the xml filter then.