I have following json
{"result": { "a": 1, "b": 2 "c": [ { "d": 3, "e": 4 }, { "d": 3, "e": 4 } ] }}
I want to change it become like this:
{"result": [{ "a": 1, "b": 2, "d": 3, "e": 4 }, { "a": 1, "b": 2, "d": 3, "e": 4 }]}
is there a way change JSON like this?
You can use
Array.prototype.reduce()for this:Or if it should be more dynamic, then like this: