Convert a hash map to array in order to split into multiple events

Hello all,

In my use case I have an XML file that contains elements that I have to convert to array of objects. Example:

<root>
 <entry first_a="a" second_a="b" first_b="c" second_b="d"/>
</root>

using the xml filter and multiple xpaths

xpath => ["//entry/first_a/text()", "result[0]first", "//entry/second_a/text()", "result[0]second"]
xpath => ["//entry/first_b/text()", "result[1]first", "//entry/second_b/text()", "result[1]second"]

I have managed to convert it to and object with the structure

"result" {
   "0" => {
        first => ["a"],
        second=> ["b"]
    },
   "1" => {
        first => ["c"],
        second=> ["d"]
    }
}

If i try to perform a split on "result", so I can handle the different result events, but I am getting an error that split only can handled array types.

I would like to convert this hash map to an array or directly put values from xpath to an array of objects.

I tried to convert the hashmap using a ruby filter but I didn't manage to.

Could you help me to transform the map to an array?

Thanks in advance,
Antony

1 Like

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