Hi,
Can anyone help me with converting multiple map into single map,
example input: {a!map(),a!Map(),a!map()}
output{a!map()}
Help is appreciated
Discussion posts and replies are publicly visible
What would this "conversion" look like? Just take the first one, or the last, or combine things somehow?
I have an output something like below, i would want to convert these 6 map items to single map and these field names are not static , field names can differ and are dynamic
So each map has an individual key and you want to combine these into a single map containing all key-value pairs?
salmak2626 Map function works with key value pair.What's key here?
Yes
it has key value pair and key are field names and value has associated value to it , i just need to merge into single map
a!localVariables( local!maps: { a!map(alpha: "a"), a!map(beta: 2), a!map(gamma: "three") }, local!keys: a!flatten( a!forEach( items: local!maps, expression: a!keys(fv!item) ) ), a!update( a!map(), local!keys, a!forEach( items: local!maps, expression: index( fv!item, a!keys(fv!item), null ) ) ) )
there are map inside map , because of that key will not fetch the key name , if i flatten complete array sets ,key wont be unique
example maps are attached and the error which i am getting is also been attached
I can't see how your data structure looks like, but I think you should be able to adapt my code to your needs. If you have a list of list of maps, it might be a good idea to put my code into a separate expression. Then use a foreach on the top level to iterate on each of the rows from the screenshot.
i will try to use it ,thanks for the help!
The above suggested code will give you the solution. You can use 'a!flatten()' to get a single list of map if you have map inside maps.
this would create an issue of duplicate key names