I need to merge JSON objects with same key into one so that it gets an object or array(doesn't matter if result is an object or array) which holds the key and an array for the values
example JSON object:
[{
"meine_frage": "hier kommt die antwort",
"ne_andere_frage": "ne andere antwort",
"was_willst_du": "alles",
"mehr_zur_auswahl": ["einiges", "vieles und", "g\u00e4r nix"]
}, {
"meine_frage": "tom & jerry",
"ne_andere_frage": "mickey maus",
"was_willst_du": "oder",
"mehr_zur_auswahl": ["manches", "einiges", "vieles und", "g\u00e4r nix"]
}, {
"meine_frage": "dick und doof",
"ne_andere_frage": "minnie muas",
"was_willst_du": "nichts",
"mehr_zur_auswahl": ["g\u00e4r nix"]
}]
result should look like:
[{
"meine_frage": ["hier kommt die antwort", "tom & jerry", "dick und doof"],
"ne_andere_frage": ["ne andere antwort", "mickey maus", "minnie muas"],
"was_willst_du": ["alles", "oder"],
"mehr_zur_auswahl": ["einiges", "vieles und", "g\u00e4r nix", "manches", "einiges", "vieles und", "g\u00e4r nix"]
}]
some values are already arrays whereas others not, the keys are genterated dynamically so assume the the key name is unkown
i tried iterating over the key/values with $.each and for loops but without success, also searched the web but couldnt find similar, appreciate any help