I have multiple dictionaries, each with a unique key, value pair. I would like to merge these dictionaries into a single dictionary. Any suggestions on how to accomplish this would be appreciated.
Discussion posts and replies are publicly visible
Hi Mike,
Thanks. I have in the meantime however come up with a solution that doesn't require any additional plugins. See below:
with( local!dictionary: cast('type!{http://www.appian.com/ae/types/2009}Dictionary', {}), local!fields: {"field1", "field2"}, local!values: {"value1", "value2"}, reduce( fn!insert(_, _, _), local!dictionary, merge( local!values, local!fields ) ) )
Kind Regards,
Philip Snyman
I Am App South Africa
I've accomplished this effectively using these three expression rules:extractKeysFromDictionary:
a!forEach( items: xpathsnippet(toxml(ri!dictionary), "/*/*"), expression: index(split(index(split(fv!item, " "), 1), "<"), 2) )
a!forEach( items: rule!extractKeysFromDictionary(ri!dictionary), expression: property(ri!dictionary, fv!item) )
reduce( fn!insert, ri!dictionary1, merge( rule!extractValuesFromDictionary(ri!dictionary2), rule!extractKeysFromDictionary(ri!dictionary2) ) )
Perfect !
You can use the Dictionary Utilities and use dictUtil_merge to merge the dictionaries.