I have two hashes that I would like to merge. they look like this:
[{"Hello"->"3"},{"Hi"->"43"},{"Hola"->"43"}]
and the second hash looks like:
[{"Hello"->"4"},{"Hi"->"2"},{"Bonjour"->"2"}]
I would like to merge these two hash arrays so that the result looks like:
[{"Hello"->[{value1=>3},{value2=>4}],{"Hi"->[{value1=>43},{value2=>2}]},{"Bonjour"->[{value1=>0},{value2=>2}]},{"Hola"->[{value1=>43},{value2=>0}]]
Is there a simple way to merge these two hashes or do I have to iterate through the hashes individually and find that key in the other hash?
The easiest way is turn the arrays of hashes to hashes:
Then you need to find all the keys:
Next, for each key, build the array of values: